In a bash script, I call another programme, but I want to configure that programme with a command line option. The following works:
AREA_ARG=""
if __SOME_SETTING__ ; then
AREA_ARG=" --area us,ca "
fi
process_data -i /some/path $AREA_ARG
i.e. bash either executes process_data -i /some/path
, or process_data -i /some/path --area us,ca
.
However shellcheck
complains!
$ shellcheck test.sh
In test.sh line 7:
process_data -i /some/path $AREA_ARG
^-------^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
process_data -i /some/path "$AREA_ARG"
For more information:
https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
I understand the principle, but I want/need the variable to split on the space so that process_data
gets 2 arguments.
What's the Proper Way™ to do this in bash
?