July 4, 2019

How to SHELL for compatible Makefiles

The upshot is if you care about maximum compatibility with different versions of GNU Make, don’t use .SHELLFLAGS just put all your args in-line in the SHELL variable, and make sure to always always use -c as your last argument. E.g. for bash in “strict mode” SHELL := /usr/bin/env bash -euo pipefail -c But why? I really care about the out of the box development experience on projects I maintain. Read more

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