TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
:- operator is a shell parameter expansion modifier used to provide a default value during variable substitution. It evaluates the state of a parameter and returns a specified fallback string if the parameter is either unset or null (an empty string).
Syntax
parameter: The name of the variable being evaluated.word: The fallback expression. This is subject to tilde expansion, parameter expansion, command substitution, and arithmetic expansion before being returned.
Evaluation Mechanics
The operator evaluates theparameter against three distinct memory states:
- Set and Not Null: If
parametercontains a value of length > 0, the expansion yields the value ofparameter. Thewordis ignored. - Unset: If
parameterhas not been declared in the current shell execution environment, the expansion yields the evaluation ofword. - Null: If
parameteris declared but contains an empty string (""), the expansion yields the evaluation ofword.
:- operator is strictly a substitution mechanism. It does not assign the evaluated word back to the parameter. To perform substitution and assignment simultaneously, the := operator is used.
State Visualization
Technical Distinction: :- vs -
The inclusion of the colon (:) dictates how the shell handles null values.
${parameter:-word}: Tests for both unset and null.${parameter-word}: Tests strictly for unset. If the parameter is null, the shell considers it a valid state and returns the empty string.
Master Bash with Deep Grasping Methodology!Learn More





