Issue
Could you help me explain the expression in BASH script ?
${1:-}
I never see it before, so I try some about it.
echo ${1:-}
echo ${1}
I cant see any difference.
Thank you very much!!!
Solution
Just a small example adapted from here
varName="Aloha"
echo "varName is not empty: the two constructs behave the same"
echo ${varName-Hello World}
echo ${varName:-Hello World}
echo ""
unset varName
echo "varName is unset: they still behave the same way"
echo ${varName-Hello World}
echo ${varName:-Hello World}
echo ""
varName=""
echo "varName is empty: this is where the two differs"
echo ${varName-Hello World}
echo ${varName:-Hello World}
echo ""
Basically :-
changes the values of the variable if it's empty or not set, and :
changes it if it's not set.
Answered By - random_user Answer Checked By - Pedro (WPSolving Volunteer)