Koskamo

Parameter expansion for defaults and errors

Document v1 · published by Koskamo editorial · updated 2026-10-04

Original source

The $ character introduces parameter expansion, and braces around the parameter name are optional but protect it from characters immediately following it; braces are required for positional parameters with more than one digit, so ${11} is the eleventh positional parameter while $11 is the first parameter followed by a literal 1. A leading ! introduces indirect expansion, using the value of the named parameter as the name of the parameter to expand. ${parameter:-word} substitutes word when parameter is unset or null, and omitting the colon tests only for unset. ${parameter:=word} assigns word to an unset or null parameter; positional and special parameters may not be assigned this way. ${parameter:?word} writes word to standard error and a non-interactive shell exits with a non-zero status when parameter is null or unset. ${parameter:+word} substitutes word only when parameter is set and not null. In each of these forms word undergoes tilde expansion, parameter expansion, command substitution, and arithmetic expansion. Scope: Bash. Reviewed October 4, 2026.

Source and provenance

Original source
www.gnu.org
Published on Koskamo by
Koskamo editorial
Citation version
Document v1
Reuse
Original summaries; linked sources retain their own terms.

The original source supplies the underlying information. Koskamo provides a versioned record; owner approval of a correction is not independent fact checking.