Respect NOCOLOR

While `nix` has always been respectful towards requests for `NO_COLOR=1`, this change asks represents a new stage of maturity for `nix` - making it also respect quests for `NOCOLOR=1`.

This ideally makes the tool more accessible to folks like me, who are exhausted by guessing whether `NO_COLOR` or `NOCOLOR` is the right environment variable to set.

<3
This commit is contained in:
Alex Ameen 2023-09-27 14:49:52 -05:00 committed by GitHub
parent 57eb62d230
commit 5bc540a8ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1515,7 +1515,7 @@ bool shouldANSI()
{ {
return isatty(STDERR_FILENO) return isatty(STDERR_FILENO)
&& getEnv("TERM").value_or("dumb") != "dumb" && getEnv("TERM").value_or("dumb") != "dumb"
&& !getEnv("NO_COLOR").has_value(); && !(getEnv("NO_COLOR").has_value() || getEnv("NOCOLOR").has_value());
} }
std::string filterANSIEscapes(std::string_view s, bool filterAll, unsigned int width) std::string filterANSIEscapes(std::string_view s, bool filterAll, unsigned int width)