Assert Bash Environment Variable
2017-08-08

I was modifying a setup script at work when I came across an environment variable not set by the script, or anywhere else in the project. Tracing back, the original code to set the variable relied on find from the current user's home directory, and was therefore not scaling well. The commit suggested moving it to any of the other places one might set environment variables (for example, Direnv).

However, there was nothing ensuring that variable existed. Seeing a good opportunity to make things clearer for the next developer to come along, I went to Stack Overflow (well, Google, but clicked the first Stack Overflow result). Not only did I find an answer, but a very thorough explaination.

This gist is just a quick example to remind myself how this technique works.