June 25, 2019

YES/NO Boolean Env Vars

I use YES and NO in environment variables to store Boolean values. I have come to the conclusion that this is in some way optimal after trying all the other obvious options and finding that each has readability flaws: 0 and 1 are confusing in POSIX shells like bash, because return 0 and exit 0 usually mean “success” (the command did not fail) which we think of as truthy. Likewise, 1 or any other non-zero number is treated as failure in these contexts, which intuitively feels falseish. Read more

© Sam Salisbury 2019