bashstyle
bashstyle copied to clipboard
set -u
I would add set -u
into your advice for set -eo pipefail
, i.e. set -euo pipefail
An enhancement to that is to fail early in a script with useful feedback.
: ${FOO:?You have not set the FOO variable}
I have mixed feelings about set -e
in a library script with a lot of functions that do something like
is_integer() {
[[ $1 =~ ^[-0-9][1-9]*$ ]]
}
…but totally agree that -u
needs to be in there 100% of the time.