Bash Bunch, Not surprisingly, bash does not exit the script when an error is detected in a subshell.
I am hopeful that someone has a solution to this (other than: be careful to not use subshells). Here is the test run: ------------------- ./subshellnofail.sh BEGIN ERROR: ./subshellnofail.sh 10 <- would like the script to stop here. ONE ERROR: ./subshellnofail.sh 10 ------------------- Here is the sample script: ------------------ #!/bin/bash set -o errexit set -o noclobber set -o nounset set -o pipefail # if you fail on this line, get a newer version of bash. function traperr { echo "ERROR: ${BASH_SOURCE[0]} ${LINENO}" # exit 1 # does not seem to affect the program. # return 1 # does not seem to affect the program. } set -o errtrace trap traperr ERR echo "BEGIN" cat /etc/passwd |while read aLine do # in a subshell test=$(true | false | true |false); done echo "ONE" while read aLine do # not in a subshell test=$(true | false | true |false); done </etc/passwd echo "TWO" test=$(true | false | true |false); echo "END" exit 0 ----------------- echo $BASH_VERSION 3.2.17(1)-release