I use `set -e` but it has its own quirks. A couple:
An arithmetic expression that evaluates to zero will cause the script to exit. e.g this will exit:
set -e
i=0
(( i++ )) # exits
Calling a function from a conditional prevents `set -e` from exiting. The following prints "hello\nworld\n":
set -e
main() {
false # does not return nor exit
echo hello
}
if main; then echo world; fi
Practically speaking this means you need to explicitly check the return value of every command you run that you care about and guard against `set -e` in places you don't want the script to exit. So the value of `set -e` is limited.
An arithmetic expression that evaluates to zero will cause the script to exit. e.g this will exit:
Calling a function from a conditional prevents `set -e` from exiting. The following prints "hello\nworld\n": Practically speaking this means you need to explicitly check the return value of every command you run that you care about and guard against `set -e` in places you don't want the script to exit. So the value of `set -e` is limited.More at https://mywiki.wooledge.org/BashFAQ/105