morrell@hpsal2.HP.COM (Michael Morrell) (03/19/88)
/ hpsal2:comp.unix.questions / kk@richp1.UUCP (Ken Konecki) / 9:01 am Mar 15, 1988 /
I've found an interesting problem with the korn and bourne shells
when it comes to dealing with command line parameters.
When this script:
echo "Number of parameters: ${#}"
for arg in $*
do
echo "Argument is $arg"
done
with the line
script '1 2 3' 4 5 6
the shell(s) output this:
Number of parameters: 4
Argument is 1
Argument is 2
Argument is 3
Argument is 4
Argument is 5
Argument is 6
------
The second line of your script should be:
for arg in "$@"
Otherwise, the shell is reexpanding the arguments, stripping off the
quotes.