Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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

share|improve this answer
    
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
add comment

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

Variable Mangling in Bash with String Operators

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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