reference Environment variables
NO_COLOR
- Also spelled
OPENGREP_FORCE_NO_COLOR,SEMGREP_FORCE_NO_COLOR- Value
- any non-empty value
- See also
--force-color,OPENGREP_FORCE_COLOR
Any non-empty value turns off color, bold and other styling in the output and in the logs, as described at no-color.org. OPENGREP_FORCE_NO_COLOR and SEMGREP_FORCE_NO_COLOR have the same effect.
Opengrep decides on styling separately for standard output and standard error, in this order:
--force-color, orOPENGREP_FORCE_COLORset to a true value, turns styling on.- Otherwise,
NO_COLORorOPENGREP_FORCE_NO_COLORturns it off. - Otherwise, the output is styled only when standard output is a terminal, and the logs only when standard error is one. A text report written to a file is not styled.
Examples
--force-color takes precedence
rule.yaml
rules: - id: find-eval pattern: eval(...) message: found eval languages: [python] severity: WARNINGapp.py
eval(code)Command and result
$ NO_COLOR=1 opengrep scan --config rule.yaml --force-color app.py | grep -q $'\e\[' && echo styled || echo plain
styled