-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty NO_COLOR environmental variable should not disable coloring #72
Comments
So someone already pointed this out and submitted a patch to fix it, which I closed, because it's very clearly a breaking change: #63 This is exactly why I regret ever adding support for Regardless of what the "spirit" of the spec was, the way I implemented it matched what the spec said. I really just don't see it changing at this point. It will break real users that did I think the right path forward is to deprecate |
Yes, I also was surprised to find this and think the spec is buggy. Empty string and unset are not the same, even in bash, the original wording has different meaning than author's intention. It's sad it ended up like this because the variable is a useful and convenient idea in general. I agree with your choice (there is no good choice here either way). I've closed this as not planned, add label:wontfix if you wish. |
Aye. For anyone else stumbling across this issue and wondering about a possible path forward, I see two:
|
Currently the
NO_COLOR
variable is handled with this code (in 2 places) -env::var_os("NO_COLOR").is_some()
.The correct version (only disable coloring when the variable is set and value is not an empty string) of this check would be
env::var_os("NO_COLOR").unwrap_or_default().len() > 0
or similar, possibly in a function (to not duplicate it) with appropriate explanation/rationale and link to https://no-color.org/ as well.I can prepare a PR with a commit like that if you agree and wish me to do that.
The wording on https://no-color.org/ is clear this is the intention, but this is a very recent change to the wording. It was done after ripgrep and many other programs added this functionality: jcs/no_color@99f90e2
I assume it was clarified to make it easier for shell scripts and some scripting languages to handle, and to allow enabling color for single command using
NO_COLOR= that-command
(I tried this today with ripgrep and it failed to enable color).The no-color author's comment https://github.com/jcs/no_color/issues/83#issuecomment-1166731293 also says this was original intended meaning, so it was essentially ambiguity in the original wording, which lead to many projects checking for just presence.
The text was updated successfully, but these errors were encountered: