| I'm not your parent comments OP, but I don't like to use -e for similar reasons, and I do have public bash scripts written with explicit error handling [1]. I've tried using -e on multiple occasions, but always had to disable it again because it lead to even worse classes of errors. It hurt me more than it helped, but I also consider my explicit error handling quite pedantic and probably not the norm. I feel that instead of fixing the problem it just shifts it around, because an exit code != 0 does not generally indicate an error: * `((i++))` must now be written as `((i++)) || true` or it will probably kill your script, and short hand conditions become foot-guns: * Statements such as `[[ $i -gt 3 ]] && continue` must now be written in long form in their own ifs, or `|| true` must be appended. * Want to save the return code? Guess you have to use `command && ret=$? || ret=$?` now. * Subshells with errors may exit independently and won't notify you of the error at all, because ylur parent is still alive afterwards. The list goes on and on. Lots of strange edge cases appear. I recommend reading http://mywiki.wooledge.org/BashFAQ/105 which highlights some of them. In the end, set -e requires you to think just as much as not using it to not randomly crash your program. It just shifts the problem to other statements. I already learned to handle errors in normal bash, and the only thing set -e requires me to do is to change my error handling style in those cases, which to me generally seem more obscure. If I still have to use set -e, I always use something like the following snippet, so that I at least get a message: ```
set -e
function eerr() { echo "error: $0:$1: command failed but status was never checked!" };
trap 'eerr "$LINENO"' ERR```
``` [1] https://github.com/oddlama/gentoo-install/blob/develop/scrip... |