Shell parameter bugs?
Michael Morrell
morrell at hpsal2.HP.COM
Sat Mar 19 05:39:20 AEST 1988
/ hpsal2:comp.unix.questions / kk at 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.
More information about the Comp.unix.questions
mailing list