Monday, 14 August 2017

Bash: The Difference Between := and :-

Cited from ${var:=default} vs ${var:-default} - what is difference? [duplicate]

They are similar only that ${var:=defaultvalue} assigns value to var as well and not just expand as like it.

Example:
$A='' "
$echo "${A:=2}"
2
$echo "$A"
$A='' "
$echo "${A:-2}"
2
$echo "$A"
(empty)


No comments:

Post a Comment