expansion

Bash Assign fallback if unset or empty

Assigns the fallback to a writable scalar if missing or empty, and yields its resulting value.

Formal Syntax & Structure

bash syntaxbash
${p:=word}

Return Value

shell expansion result

Assigns the fallback to a writable scalar if missing or empty, and yields its resulting value.

Working Example

Example Snippetbash
p=printf '%s\n' "${p:=blue}" "$p"
Bash Reference