# The ERR trap runs for the last command too. A failing external command # as the last thing a shell runs is exec'd, and the shell is gone before # the trap could run, unless the trap holds that shortcut back. So does a # subshell that would otherwise run in the parent. "$TSH" -c 'trap "echo ERR" ERR; /bin/false'; echo "[$?]" "$TSH" -c 'trap "echo ERR" ERR; false'; echo "[$?]" "$TSH" -c 'trap "echo ERR" ERR; (/bin/false)'; echo "[$?]" "$TSH" -c 'trap "echo ERR" ERR; trap "echo BYE" EXIT; /bin/false'; echo "[$?]"