Hi! It seems that in bash version 4.0.33(1)-release (i486-pc-linux-gnu) (from Ubuntu 9.04), ERR traps are not inherited by functions that are called via command substitution. I expected inheritance to apply in this case since the documentation of 'set -E' promises inheritance of the ERR trap for subshell contexts. The script below illustrates this behavior as the trap action err_handler() is not called.
Is this behaviour intended? Even if so, I'd like to say that I would find ERR
trap inheritance for command substitution extremely useful :-)
Cheers,
Stefan
#!/bin/bash
err_handler() {
echo "THERE WAS AN ERROR"
}
set -E
trap 'err_handler' ERR
myfunc() {
false # fails to cause an ERR trap
true
}
FOO=$(myfunc)
exit 0
signature.asc
Description: OpenPGP digital signature
