2025-04-25
last update: 2025-04-25
Set -euxo pipefail
To make working with Bash scripts less problematic, I've switched to these default shebang and settings:
#!/usr/bin/env bash
set -euxo pipefail
The first line tells the interpreter to run the file via bash
as found at /usr/bin/env
. This /usr/bin/env
is one of the most platform-independent locations that I know (it even works on NixOS).
The second line makes it much easier to find problems in the script. The -e
option will cause the script to fail immediately when a command fails, the -o pipefail
will also crash if one of the commands in a pipe fails (this could have avoided a Cloudflare outage), -u
will treat unset variables as error, and -x
will print each command before execution.