Reputation: 21
I see the doc here
${parameter-default}, ${parameter:-default} If parameter not set, use default.
and
${parameter=default}, ${parameter:=default} If parameter not set, set it to default.
I did some test and didn't find and different,anything i missed?
Upvotes: 0
Views: 44
Reputation: 385860
The difference is that ${parameter=default}
sets parameter
if it was unset.
Here, ${x-foo}
leaves x
unset:
; unset x
; echo ${x-foo}
foo
; echo $x
;
But here, ${x=foo}
sets x
to foo
:
; echo ${x=foo}
foo
; echo $x
foo
;
Upvotes: 2