Bash shell scripting variables

I have the following line in my shell script:

if [ -n "${USE_X:+1}" ]; then

I cannot figure out what the ":+1" part means. Any ideas?

Answers


Have a look here. That url provides the following explanation:

${parameter:+alt_value} If parameter set, use alt_value, else use null string.

and has the following example:

echo
echo "###### \${parameter:+alt_value} ########"
echo

a=${param4:+xyz}
echo "a = $a"      # a =

param5=
a=${param5:+xyz}
echo "a = $a"      # a =
# Different result from   a=${param5+xyz}

param6=123
a=${param6:+xyz}
echo "a = $a"      # a = xyz

Need Your Help

MySQL TEXT or VARCHAR

mysql text storage varchar

We have a very large historical table that contains a column with at most 500 UTF8 characters, and the disk space grows really fast!

enhanced ecommerce analytics tracking on new tracker

google-analytics enhanced-ecommerce

I wanted to setup a separate account for enhanced ecommerce data so the data doesn't alter the main account