-errexit: exit the script when a command fails
-nounset: fail when referencing an unset variable
-pipefail: fail when the any command in a pipeline fails, not just the last one
The last option is unfortunately harder to use, since some programs misbehave in pipelines.