🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.sys5
Article #1138

Re: bug in /bin/sh

#1138
From: E. Mike Durbin
Date: Fri, 26 May 1989 16:14
50 lines
1263 bytes
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
Technical Details
Message-ID: <352@richsun.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!richsun!emike
References: <883@cetia4.UUCP>

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