26

I have a bash code export TM_SCALAC=${TM_SCALAC:-scalac}.

I'm not sure the meaning of ":-" inside the ${}. How do I interpret this line of bash code?

1

1 Answer 1

28

That means if TM_SCALAC isn't already set, set it to "scalac".

From bash reference manual:

3.5.3 Shell Parameter Expansion

...

${parameter:-word} If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.

Not the answer you're looking for? Browse other questions tagged .