bash assign default value

前端 未结 4 1693
一生所求
一生所求 2020-12-22 16:55

${parameter:=word} Assign Default Values. If parameter is unset or null, the expansion of word is assigned to parameter. The value of pa

4条回答
  •  [愿得一人]
    2020-12-22 17:44

    Use a colon:

    : ${A:=hello}
    

    The colon is a null command that does nothing and ignores its arguments. It is built into bash so a new process is not created.

提交回复
热议问题