News for hackers. Stuff that matters.
Re:No_color by rsync on Saturday February 26, 2022 @07:40PM (#30483951)
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 ?

Re:No_color by quesera on Saturday February 26, 2022 @07:47PM (#30484027)
I 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
Re:No_color by Monory on Saturday February 26, 2022 @08:02PM (#30484165)
Well, in ZSH [[ -v VAR ]] can actually differentiate between unset and null variables

And

NO_COLOR=

would lead to an non-intuitive behavior

Re:No_color by Aeolun on Saturday February 26, 2022 @09:37PM (#30484794)
I think the implication is that it should have a value.
Re:No_color by chrisseaton on Saturday February 26, 2022 @07:50PM (#30484056)
> 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.

Re:No_color by scatters on Saturday February 26, 2022 @09:22PM (#30484693)
It makes the logic simple in C (where the empty string is truthy); you can just write `if (getenv("FOO"))`.