reference Environment variables
OPENGREP_FORCE_COLOR
- Also spelled
SEMGREP_FORCE_COLOR- Value
true,yes,1orfalse,no,0- Equivalent to
--force-color- See also
NO_COLOR
Read when neither --force-color nor --no-force-color is given. A true value styles the output even when it goes to a pipe or a file, and takes precedence over NO_COLOR. A false value keeps the default, in which only output to a terminal is styled.
The accepted values are true, yes and 1 for true, and false, no and 0 for false. Any other value is rejected like an invalid flag value, with exit status 2.
Examples
Color through a pipe, from the environment
rule.yaml
rules: - id: find-eval pattern: eval(...) message: found eval languages: [python] severity: WARNINGapp.py
eval(1)Command and result
$ opengrep scan --config rule.yaml app.py | grep -q $'\e\[' && echo styled || echo plain
plain
$ OPENGREP_FORCE_COLOR=1 opengrep scan --config rule.yaml app.py | grep -q $'\e\[' && echo styled || echo plain
styled
$ OPENGREP_FORCE_COLOR=1 opengrep scan --config rule.yaml --no-force-color app.py 2>/dev/null | grep -q $'\e\[' && echo styled || echo plain
plain