4 ms·
I think this is a fine idea but I wonder about this part: "... should check for the presence of a NO_COLOR environment variable that, when present (regardless
by rsync 5y ago
I think this is a fine idea but I wonder about this part:
"... should check for the presence of a NO_COLOR environment variable that, when present (regardless of its value), prevents the addition of ANSI color ..."
How common is this behavior ?
That is, the presence of the env var regardless of its value trips the conditional ?
That seems like asking for trouble / confusion ... especially since there is a very well understood practice of setting 0/1 false/true for settings like this.
Is this commonly done and I have just never noticed it ?
- quesera 5y agoI think it's fairly common. NO_COLOR=1 NO_COLOR=true NO_COLOR=yes Rather than parsing all the permutations, the usual evaluation of env vars that are expected to hold a boolean type is just the equivalent of: #ifdef NO_COLOR
- chrisseaton 5y ago> That is, the presence of the env var regardless of its value trips the conditional ? Pretty normal, yeah. You can `unset FOO` a variable to set it to false.
- scatters 5y agoIt makes the logic simple in C (where the empty string is truthy); you can just write `if (getenv("FOO"))`.