reference Flags

--lang

Accepted by
opengrep scan
Also spelled
-l
Value
LANGUAGE
See also
--pattern, --show-supported-languages, --scan-unknown-extensions, languages

Sets the language of the pattern given with -e/--pattern. The pattern and the targets are parsed as that language, so the same pattern can match differently under -l python and -l js.

The two flags must be given together. LANGUAGE is any name or alias that --show-supported-languages lists: python, py and python3 are equivalent.

Rules from a rule file name their languages in languages, and do not use --lang.

Examples

The same pattern, a different language

app.js
eval(1)
Command and result
$ opengrep scan -q -e 'eval(...)' -l js app.js
app.js

     1: eval(1)