Skip to content
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

NO_COLOR implementation doesn't match the spec #38

Closed
chocolateboy opened this issue Sep 25, 2020 · 4 comments · Fixed by #39
Closed

NO_COLOR implementation doesn't match the spec #38

chocolateboy opened this issue Sep 25, 2020 · 4 comments · Fixed by #39

Comments

@chocolateboy
Copy link

NO_COLOR is meant to disable color regardless of the value:

All command-line software which outputs text with ANSI color added should check for the presence of a NO_COLOR environment variable that, when present (regardless of its value), prevents the addition of ANSI color.

i.e. all of the following should disable color:

$ NO_COLOR=1 command  # ✔ 
$ NO_COLOR=0 command  # ✔
$ NO_COLOR= command   # x
$ NO_COLOR="" command # x

But the current implementation expects it to be truthy:

enabled: !NODE_DISABLE_COLORS && !NO_COLOR && TERM !== 'dumb' && (

@lukeed
Copy link
Owner

lukeed commented Sep 25, 2020

Ah, thanks! Even though it's in bold, I overlooked it 😆 Probably a cross-language thing? FOO=0 feels like it should always be an off-flag.

PR welcome, otherwise I probably won't get to it later today.

//cc @stramel since it might be a surprise to you too

@chocolateboy
Copy link
Author

FOO=0 feels like it should always be an off-flag.

Yes, it's an annoying misfeature of the NO_COLOR spec (no other environment variables I'm aware of behave like it :-)

@lukeed
Copy link
Owner

lukeed commented Sep 25, 2020

How did you encounter this? Were you actually trying to do NO_COLOR= or NO_COLOR=0 in real usage?

@chocolateboy
Copy link
Author

Trying to get FORCE_COLOR to not work like NO_COLOR in another library...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants