parameter-expansion

Bash ${name-word} — default when unset

Substitutes word only if name is unset; an explicitly empty value is preserved. Does not assign the default.

Formal Syntax & Structure

bash syntaxbash
${name-word}

Parameters & Attributes

NameTypeDescription
name, wordstringParameter and fallback word.

Return Value

string

Parameter value or fallback.

Working Example

Example Snippetbash
unset labelprintf '%s\n' "${label-fallback}"label=printf '[%s]\n' "${label-fallback}"
Bash Reference