3 ms·
You're missing `errtrace` (-E) which means "any trap on ERR is inherited by shell functions, command substitutions, and commands executed in a subshell environm
by phaemon 6y ago
You're missing `errtrace` (-E) which means "any trap on ERR is inherited by shell functions, command substitutions, and commands executed in a subshell environment"
You probably haven't used it much if you haven't been using `trap`
- usr1106 6y agoI 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...