Shell Parameter Expansion

echo $ENV_VARIABLE
echo ${ENV_VARIABLE-Not Present} //prints Not Present, as variable 
not present
export ENV_VARIABLE= //variable present but not set
echo ${ENV_VARIABLE-Not Present} //prints nothing as variable is
present
echo ${ENV_VARIABLE:-Not Present} //prints Not Present, as 
variable is not present
export ENV_VARIABLE= //variable present but not set
echo ${ENV_VARIABLE-Not Set} //prints Not Set as variable is
null
echo ${ENV_VARIABLE:=DEFAULT_VALUE} //assigns and prints 
DEFAULT_VALUE to variable as
variable not present
export ENV_VARIABLE= //variable present but not set
echo ${ENV_VARIABLE:=DEFAULT_VALUE} //assigns and prints
DEFAULT_VALUE to variable as
variable null
export ENV_VARIABLE="I learned"   //variable present and set
echo ${ENV_VARIABLE:?Everything} //prints Everything as value
is present

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store