diff options
author | Einhard Leichtfuß <alguien@respiranto.de> | 2024-12-23 12:28:30 +0100 |
---|---|---|
committer | Einhard Leichtfuß <alguien@respiranto.de> | 2024-12-23 12:28:30 +0100 |
commit | 6598c9a8d195193cf168cbee515bd383d69c1a1b (patch) | |
tree | 10c8f00e30a749452ced34e4e6fe374510e44d8f /src/basic.bash | |
parent | d66984da0a9c85399da30811e2006c8e609965fd (diff) |
Add errexit, inherit_errexit
Also amended related notes in `docs/`.
See comments and `docs/error-handling.md` on why.
Diffstat (limited to 'src/basic.bash')
-rw-r--r-- | src/basic.bash | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/basic.bash b/src/basic.bash index a951e0c..a9d0a10 100644 --- a/src/basic.bash +++ b/src/basic.bash @@ -63,10 +63,19 @@ trap 'basic::print_stacktrace 0; exit 1' ERR # Inherit traps on ERR. set -o errtrace -# If we didn't trap ERR (and exit on ERR), we'd likely want the below. +# Exit on ERR. +# - This is mostly made redundant by the ERR trap (which causes an exit). +# - However, in some cases, the ERR trap does not apply, while `errexit` does: +# - `var[0]=(foo bar)`, when not in a subshell. +# - Same for an associative array. +# - It is unclear why `errexit` and the ERR trap apply on different +# conditions. +# - `inherit_errexit` seems indeed irrelevant in our case, but we enable it +# for consistency. # - Note: `inherit_errexit` is similar to `errtrace`. -#set -o errexit -#shopt -s inherit_errexit +# - See also: `/docs/error-handling.md#Array_variables` +set -o errexit +shopt -s inherit_errexit ## How to act on exit. |