I am looking at parameter expansion using ${parameter:-word}
versus ${parameter:=word}
.
Here is some relevant documentation:
${parameter:-word}
If parameter is unset or null, the expansion of word is substituted.
${parameter:=word}
If parameter is unset or null, the expansion of word is assigned to parameter. The value of parameter is then substituted.
Certainly, the key difference is in the first sentence of each description, substituted versus assigned.
But in actuality, I do not know what happens when something is substituted
versus when something is assigned
.
Finally, when is it appropriate to use one versus the other?
echo "${parameter:-word}"
does not actually assign word toparameter
immediately, – Pietru Jul 07 '21 at 23:43dir=${dir:-$PWD}
andfltype=${fltype:="texi,org"}
. But I do not know whether to use:-
or:=
. – Pietru Jul 07 '21 at 23:47${parameter:-word}
rather than${parameter:=word}
. – Pietru Jul 08 '21 at 01:13