This question already has an answer here:
I have a shell script inside of which I call a command with several arguments. When I call the command from the terminal, the proper syntax is:
command --foo='bar baz'
Inside my script, I want to have
--foo='bar baz' inside a variable $ARGS, so that I can put
in my script. However, if I simply assign
$ARGS="--foo='bar baz'" then the string
'bar gets passed as the parameter for foo instead of the complete string
bar Every combination of quotes/escaped quotes that I've tried has resulted in either nothing being passed, or just'bar` or something similar. I've looked into parameter expansion in bash but am not quite sure how it works.
I would just copy/paste the entire command and its arguments instead of using variables but I call the command in multiple places in the script and want to minimize code re-use, as the complete list of arguments is several lines long.