Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!cs.utexas.edu!uunet!edsews!bgalli!bga From: bga@bgalli.eds.com (Billy G. Allie) Newsgroups: comp.bugs.sys5 Subject: Re: bug in /bin/sh Summary: It's not a bug ... it's a feature! Keywords: functions, quotes Message-ID: <349@bgalli.eds.com> Date: 26 May 89 04:05:57 GMT References: <883@cetia4.UUCP> Organization: BGA's home system, Dearborn, MI. Lines: 30 In article <883@cetia4.UUCP>, chris@cetia4.UUCP (Christian Bertin) writes: > First, I apologized if this is an ancient bug. There is a problem in the > argument passing when shell functions are used: The expansion of $* turns > quoted strings into multiple arguments. > > But, if I type: > > $ mail() /usr/bin/mailx $* > $ mail -s "a b c d e f" chris > > the quoted string has become multiple arguments to 'mailx' The shell expand the parameters $* and $@ into a list of all positional parameters seperated by spaces so that the following command is executed: /usr/bin/mailx -s a b c d e f chris To get the effect you desire, you must use the $@ parameter within quotes. For example, your mail function should be written as follows: mail() /usr/bin/mailx "$@" Note that both the $* and the $@ parameters receive special treatment by the shell when they are quoted. "$*" is equivalent to "$1 $2 $3 ..." and "$@" is equivalent to "$1" "$2" "$3" .... -- ____ | Billy G. Allie | Internet..: bga@bgalli.eds.com | /| | 7436 Hartwell | UUCP......: uunet!{mcf|edsews}!bgalli!bga |-/-|----- | Dearborn, MI 48126 | Compuserve: 76337,2061 |/ |LLIE | (313) 582-1540 | Genie.....: BGALLIE