Executing this command gives the expected output - the "c d" is handled as a single argument:
% /bin/sh -c 'args="$@"; for a in "$@"; do echo $a; done' -- a b "c d"
a
b
c d
If the same argument is stored in a file and passed to script by cat
, I got the undesired output - the "c d" is handled as 2 arguments:
% echo a b \"c d\" > foo
% cat foo
a b "c d"
% /bin/sh -c 'args="$@"; for a in "$@"; do echo $a; done' -- `cat foo`
a
b
"c
d"
Is there any way to make the argument passed as result of command execution be handled as it were passed as a string?
Tks