Closed kerolasa closed 6 years ago
Oh nice! I'll read up on this later.
This works
set -E
mortal() {
false
echo 'Supposedly unreachable'
}
trap 'echo "Failed in $FUNCNAME."; exit 1' ERR
mortal
but not this
set -E
mortal() {
false
echo 'Supposedly unreachable'
}
trap 'echo "Failed in $FUNCNAME."; exit 1' ERR
if mortal; then
true
fi
→ set -E
suffers the same problem!
FYI. New versions of bash has set -E that 'If set, the ERR trap is inherited by shell functions'. That should make gotcha more and less annoying. By that I mean it is easy to avoid 'set -e' in every single function, but one still may have to go and update whole bunch of old scripts to use -E rather than -e.