What does ${ARGUMENT+x} mean in Bash?

It means that if $ARGUMENT is set, it will be replaced by the string x

Let's try in a shell :

$ 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 modern bash, one would use the -v operator instead:

if [[ -v ARGUMENT ]]; then

Tags:

Bash