4

In a bash script I cannot post here I see the following expression:

${MYVAR:+-x}

I understand the meaning of expressions like ${MYVAR:+OTHERVAR} and ${MYVAR:-OTHERVAR}, but an expression with both a plus-sign and a minus-sign. What does it mean, if anything?

1 Answer 1

2

This is the same as

${MYVAR:+OTHERVAR}

with OTHERVAR being equal to -x. In other words, if MYVAR is unset or null, substitute null; otherwise, substitute -x.

References

You must log in to answer this question.

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