Home > Blockchain >  Operator in variable affectation [duplicate]
Operator in variable affectation [duplicate]

Time:09-21

I'm trying to understand the syntax of an existing ksh script. I came across the following line:

HOME_APP=${HOME_APP:-/app}

What does it mean?

CodePudding user response:

Seems like there must be a duplicate for this, but :- is used to supply a default value for the expansion when HOME_APP is unset or null.

$ unset HOME_APP
$ echo "${HOME_APP:-/app}"
/app
$ HOME_APP=
$ echo "${HOME_APP:-/app}"
/app
$ HOME_APP=/opt
$ echo "${HOME_APP:-/app}"
/opt
  • Related