I have a bash script that uses the following syntax:
if [ ! -z ${ARGUMENT+x} ]; then
What is the meaning of the "+x" syntax after the argument name?
I have a bash script that uses the following syntax:
if [ ! -z ${ARGUMENT+x} ]; then
What is the meaning of the "+x" syntax after the argument name?
 
    
     
    
    It means that if $ARGUMENT is set, it will be replaced by the string x
$ echo  ${ARGUMENT+x}
$ ARGUMENT=123
$ echo  ${ARGUMENT+x}
x
You can write this with this form too :
${ARGUMENT:+x}
It have a special meaning with :, it test that variable is empty or unset
Check bash parameter expansion
 
    
    Rather than discussing the syntax, I'll point out what it is attempting to do: it is trying to deterimine if a variable ARGUMENT is set to any value (empty or non-empty) or not. In bash 4.3 or later, one would use the -v operator instead:
if [[ -v ARGUMENT ]]; then
