bug in /bin/sh
E. Mike Durbin
emike at richsun.UUCP
Sat May 27 02:14:34 AEST 1989
In article <883 at cetia4.UUCP> chris at cetia4.UUCP (Christian Bertin) writes:
>But, if I type:
>
> $ mail() /usr/bin/mailx $*
> $ mail -s "a b c d e f" chris
>
The problem is the arguments are reevaluated after they are assembled
by the function (or shell script). $* dosn't group them. That is why
you have all seperate arguments (the "'s are gone when they are
reevaluated). "$*" will expand as "$1 $2 $3". This also is not what
you want. "$@" will expand as "$1" "$2" "$3". This *IS* what you want:
tst()
{
echo '"$@"'
for i in "$@"
do
echo "-> $i"
done
echo '"$*"'
for i in "$*"
do
echo "-> $i"
done
echo '$*'
for i in "$*"
do
echo "-> $i"
done
}
$ tst "a b c" d
"$@"
-> a b c
-> d
"$*"
-> a b c d
$*
-> a
-> b
-> c
-> d
E. Mike Durbin
Rich Inc.
uunet!richsun!emike
More information about the Comp.bugs.sys5
mailing list