Path: utzoo!attcan!uunet!richsun!emike From: emike@richsun.UUCP (E. Mike Durbin) Newsgroups: comp.bugs.sys5 Subject: Re: bug in /bin/sh Keywords: functions, quotes Message-ID: <352@richsun.UUCP> Date: 26 May 89 16:14:34 GMT References: <883@cetia4.UUCP> Reply-To: emike@richs9.UUCP (E. Mike Durbin) Organization: RICH Inc. , Franklin Park,IL Lines: 50 In article <883@cetia4.UUCP> chris@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