Even within the EXIT trap, the -u error exit status disappears when -e is used (?):
$ (set -u; trap 'echo $?' EXIT; echo $bad) bash: bad: unbound variable 1 $ (set -eu; trap 'echo $?' EXIT; echo $bad) bash: bad: unbound variable 0 Freddy Vulto http://fvue.nl