🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.sys5
Article #1139

Re: bug in /bin/sh

#1139
From: Billy G. Allie
Date: Fri, 26 May 1989 04:05
30 lines
1667 bytes
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
Technical Details
Message-ID: <349@bgalli.eds.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!cs.utexas.edu!uunet!edsews!bgalli!bga
References: <883@cetia4.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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