Skip to content

Conversation

@hoijui
Copy link

@hoijui hoijui commented Apr 13, 2023

Intro

From the man page of set in BASH:

-u Treat unset variables as an error when substituting.

In other words - like many of the other set parameters - this allows a script to fail-fast.
Using when editing the script in a modern editor/IDE, also enables linting for those errors.

What it's changing and/or adding?

Where $1 and $2 are used and they might be unset, this change replaces them with ${1:-} and ${2:-},
which means "use $1 if set, else the empty string"

What OS and/or Bash version it happens? (fix only)

All, if set -u is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant