Aaron Maxwell has a blog post titled “Use the Unofficial Bash Strict Mode (Unless You Looove Debugging)” He claims a few simple script settings will make your bash scripts “more robust, reliable and maintainable” and I think he’s right.
Let’s start with the punchline. Your bash scripts will be more robust, reliable and maintainable if you start them like this:
set -euo pipefail
There’s some good discussion on this technique at the ENHANCING THE (UNOFFICIAL) BASH STRICT MODE post if you want to read more on it.