I also include set -o pipefail (exit if ANY command in a pipeline fails). Had to get bitten and waste an hour before that became a habit.
set -e and set -o pipefail really should have been the default, rather than an opt-in.
set -e and set -o pipefail really should have been the default, rather than an opt-in.
Consider /tmp/test.sh:
set -o pipefail
yes foo | head
$ bash /tmp/test.sh >/dev/null
$ echo $?
141I've collated other mishandling of closed pipes at: http://www.pixelbeat.org/programming/sigpipe_handling.html