Path: utzoo!attcan!uunet!ubvax!ardent!worley From: worley@ardent.UUCP (John Worley) Newsgroups: comp.bugs.sys5 Subject: Re: bug in /bin/sh Message-ID: <6683@ardent.UUCP> Date: 26 May 89 00:00:48 GMT References: <883@cetia4.UUCP> Organization: Dana Computer, Inc., Sunnyvale, CA Lines: 50 > There is a problem in the > argument passing when shell functions are used: The expansion of $* turns > quoted strings into multiple arguments. The expansion of $1, for example, > works fine: > Not really. Parameters are substituted before the command is parsed, so any white space in the parameter will be seen as separating the arguments, unless the parameter is enclosed in "". The example print() { echo $1 } when invoked with, is executed as follows: print "a b" c -> echo $1 -> echo a b # Note - 2 params! -> a b visually indistinguishable from print() { echo "$1" } which is what you though was happening. > But, if I type: > > $ mail() /usr/bin/mailx $* > $ mail -s "a b c d e f" chris This is defintely NOT a bug. From the manual page for the Bourne shell: * If $* is within a pair of double quotes, the positional * parameters are substituted and quoted, separated by quoted * spaces ("$1 $2 ..."); however, if $@ is within a pair of * double quotes, the positional parameters are substituted and * quoted, separated by unquoted spaces ("$1" "$2" ... ). So, /bin/sh is behaving as documented; what you wanted was: mail() { /usr/bin/mailx "$@" } Regards, John Worley uunet!ardent!worley