exit script immediately when a command fails

1
2
set -o errexit
set -e

output error and exit script immediately when refer to a undefine variable.

1
2
set -o nounset
set -u

exit script even a command fails before a pipe

1
set -o pipefail