I have seen a line of shell script as follows:

local soft_upgrade=${3:-false}

What does this mean? I don't know what 3:-false means.


No, it's nothing about array, it's a default value in parameter substitution.

If $3 is not set, set soft_upgrade to false, otherwise, set it to $3

  • This also applies when $3 is null, not just when it is unset. – Chris Down Feb 21 '13 at 10:07
  • 1
    Just "false", not "-false", :- is the specific parameter expansion operation. – mr.spuratic Feb 21 '13 at 10:15

Take a look at this article, for me it was really useful:

Variable Mangling in Bash with String Operators

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.