-e Exit immediately if a pipeline (which may consist of a single simple
command), a list, or a compound command (see SHELL GRAMMAR above), ex‐
its with a non-zero status.
.
.
.
A trap on ERR, if set, is executed before the shell exits.
This option applies to the shell environment and each subshell envi‐
ronment separately (see COMMAND EXECUTION ENVIRONMENT above), and may
cause subshells to exit before executing all the commands in the sub‐
shell.
We would need to add also -E bash option:
-E If set, any trap on ERR is inherited by shell functions, command sub‐
stitutions, and commands executed in a subshell environment. The ERR
trap is normally not inherited in such cases.
This would simplify the debug mode.
From man trap:
We would need to add also -E bash option: