In a shell script I want a variable p
to be equal to "$@"
, so that the following two lines of code produce the same result:
for x in "$p"; do echo $x; done
for x in "$@"; do echo $x; done
If I do p=$@
or p="$@"
this doesn't work.
When the command line arguments have spaces in their names, I can't find a simple workaround to this problem (the combination p="$@"
and for x in $p
(quotes removed around $p) works when there are no spaces).