Bash Script Automatic Exit on Command Failure

Stick this at the top of your multi-command BASH job scripts:

set -e -o pipefail

Exits on failure (== non-0 return code from any commands in the script) instead of cheerfully executing all subsequent lines in what is bound to result in a cascade of errors (or worse).

More information in the excellent post here.