by elygre · 5y ago · 0 comments
set -Eeuo pipefail
But I do know this one, which appears to be missing one: set -o pipefail -o errexit -o nounset
So, one step up: Use long options and long names. Make it readable, and not just writable.> E If set, any trap on ERR is inherited by shell functions, command substitutions, and commands executed in a subshell environment. The ERR trap is normally not inherited in such cases.
set -eu is at least 30 years old. Not sure whether it makes sense to rewrite established code.
You probably haven't used it much if you haven't been using `trap`
trap EXIT
With set -eu
errors in subshells should lead to an exit anyway, so my exit handler is called. Or am I missing some case?So I'm sticking with just set -eu and trap EXIT...
Usually I have to look up what the long options are, since I've generally only memorized the short ones, but it helps immensely with readability, particularly for someone who hasn't memorized the short ones, who can now just semantically understand the options.