I am looking at several bash scripts that use :=between ${ }. For example, the template is as follows:
:=
${ }
export VAR=${VAR:=value}
What does it do? Does it assign a value to VAR if the VAR does not exist?
According to the documentation :
$ {parameter: = word}If the parameter is not specified or null, the word extension is assigned to the parameter. Then the parameter value is replaced. Therefore, you cannot assign positional parameters and special parameters.
$ {parameter: = word}
If the parameter is not specified or null, the word extension is assigned to the parameter. Then the parameter value is replaced. Therefore, you cannot assign positional parameters and special parameters.
, VAR , /null, value.
value
man:
${parameter:=word} Assign Default Values. If parameter is unset or null, the expansion of word is assigned to parameter. The value of param‐ eter is then substituted. Positional parameters and special parameters may not be assigned to in this way.
, . unset/null, , .
.
${foo:=bar}
$foo, . "bar" foo, . , . , :
$foo
"bar"
foo
: ${foo:=bar}
, , . ,
foo=${foo:-bar}
and I think this is more obvious to most readers.
Source: https://habr.com/ru/post/1534881/More articles:Deeply nested groups in RegEx - javascriptЕсть ли версия LINQKit для EF 5.0? В противном случае, что я могу использовать для EF 5.0? - expressioncan write to rs232 serial tool but cannot read from it - pythonWhat is the shortest regular expression I can write to insert 3 characters into a string? - stringPrimeFaces RequestContext.getCurrentInstance (). Update () does not work - jsf-2cocostudio: How to use the exported scene file. Does CCSceneReader work for everyone? - cross-platformJava TemporaryFolder getRoot () exception - javaЯвляется ли prom.all полезным, учитывая, что javascript выполняется в одном потоке? - javascriptgetCurrentTime () for a YouTube video - google-chrome-extensionThe DOM function works in the console, but not in the extension, despite waiting for it to load - javascriptAll Articles