bashstyle icon indicating copy to clipboard operation
bashstyle copied to clipboard

set -u

Open petef4 opened this issue 8 years ago • 1 comments

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}

petef4 avatar Apr 05 '16 11:04 petef4

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.

ernstki avatar Oct 18 '20 13:10 ernstki