What is the difference between “var=${var:-word}” and “var=${var:=word}”?

后端 未结 4 1677
北恋
北恋 2020-12-14 03:10

I read the bash man page on this, but I do not understand the difference. I tested both of them out and they seem to produce the exact same results.

I want to set a

4条回答
  •  鱼传尺愫
    2020-12-14 03:26

    You sometimes see the assignment expansion with the : command:

    # set defaults
    : ${foo:=bar} ${baz:=qux}
    

提交回复
热议问题