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
| Name | Type | Description |
|---|---|---|
| name, word | string | Parameter 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}"