set -o nounset set -o errexit http://robertmuth.blogspot.fr/2012/08/better-bash-scripting-in-15-minutes.html