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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0