25

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?

prosseek
  • 8,418
  • 16
  • 47
  • 43
  • 2
    Related: [What does `:-` mean in a shell script](http://unix.stackexchange.com/questions/30470/what-does-mean-in-a-shell-script) – Ivan Chau Dec 06 '13 at 01:23

1 Answers1

27

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.

jlliagre
  • 60,319
  • 10
  • 115
  • 157