How to pass quoted parameters to another program
问题 In a bash script, I need to pass a parameter to another program. The parameter has spaces in so must be quoted. Everything works fine in this simple case 1: /bin/echo /some/command --param="abc def ghi" Output: /some/command --param=abc def ghi The problem begins if I want to make the bash script more sophisticated, somehow the parameter value has changed in case 2 and 3: FOO="ghi" DEFAULTS="--param=\"abc def $FOO\"" /bin/echo /some/command $DEFAULTS DEFAULTS='--param="abc def '$FOO'"' /bin