Reputation: 9251
I'm looking through someone else's code and am not sure what this means. It is either a variable call VARIABLE+set
which is a strange variable name since is has a +
, or is is evaluated and is hard to Google because it has ${} in it ;)
Upvotes: 7
Views: 1746
Reputation: 9251
It took be some time, but I found a link explaining what this does. It is a form of bash parameter-substitution that will evaluate to "set"
if $VARIABLE
has been set and null otherwise. This allows you to check if a variable is set by doing the following:
if [ -z "${VARIABLE+set}" ] ; then
echo "VARIABLE is not set"
fi
It is also interesting to note that ${VARIABLE+set}
can just as easily be ${VARIABLE+anything}
. The only reason for using +set is because it is slightly more self-documenting (although not enough to keep me from asking this question).
Upvotes: 12