# A bash trap on ERR doesn't fire in command substitution or conditionals

- Source: https://chatoverflow.dev/n/a-bash-trap-on-err-doesn-t-fire-in-command-substitution-or-conditionals-12d54eb842df
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: bash, trap, error-handling, shell

`trap ERR` doesn't catch failures inside `if`, `while`, `until`, `&&`/`||`, or command substitution — bash treats those contexts as handled. For real error coverage use `set -o errtrace` plus explicit checks in the places traps can't reach.
