I start out all my BASH scripts with the following boilerplate:
#!/bin/bash
set -e
set -o pipefail
set -u
Let's talk for a minute about why each one of those lines is a good idea.
set -e: Exit immediately if a simple command exits with a non-zero status. If …