I have found this in an old script but can't tell what is the use of the "x" infront of the ${VARIABLE}
and infront of the value "onx" being compared
VARIABLE="${VARIABLE:-"on"}"
if [ "${VARIABLE}x" != "onx" ]
Are there any effects if the x
is removed?
bash
, there will be no difference to the outcome of the test ifx
is removed. See the dupe questions. – Kusalananda Feb 16 '21 at 07:51VARIABLE
to a value if it's either unset or empty. Since nowVARIABLE
cannot be empty thex
guard isn't required – Chris Davies Feb 16 '21 at 08:40