3 ms·
I use just trap EXIT With set -eu errors in subshells should lead to an exit anyway, so my exit handler is called. Or am I missing some case?
by usr1106 6y ago
I use just
trap EXIT
With
set -eu
errors in subshells should lead to an exit anyway, so my exit handler is called. Or am I missing some case?
- phaemon 6y agoI can't think of any difference if you're trapping both with the same handler. Probably only if you want a separate handler for ERR vs EXIT.
- Liskni_si 6y agoI often set up a temporary directory at the beginning and then clean it up in an EXIT trap. Adding ERR and errtrace (-E) would remove the tmpdir or the first failure anywhere, no matter if it's a recoverable one. So I'm sticking with just set -eu and trap EXIT...