Dev Tools · 2h ago
Why `set -e` in Bash Scripts Often Does More Harm Than Good
The `set -e` option in bash scripts causes immediate exit on any non-zero return, even from legitimate commands like grep (returns 1 when no match) or arithmetic comparisons. This leads to silent failures in scripts that use commands with expected non-zero exits. The article recommends explicit error checking instead of relying on `set -e`.
Meridian48 take
While the advice is sound for many scripts, `set -e` can still be useful in simple, well-understood contexts; the key is knowing when to disable it locally.
bash-scriptingerror-handling