$@ vs. $*

Arthur David Olson ado at elsie.UUCP
Wed Dec 17 02:32:48 AEST 1986


The problem:  you set up a one-line "sh" script named "feline" that reads
	c "$@"
hoping that you can then use the command "c" rather than "cat".  But
things go awry if you
	grep uucp /etc/passwd | c

Another poster's earlier posting:  a fix to "sh" to handle
	"$@"
the way it "ought" to be handled, with a wise caution that scripts relying on
the fixed sh's handling of "$@" won't be portable.

My notion:  instead of changing the behavior of "$@", introduce a new '$'
sequence that does what
	"$@" 
ought to do--for example, set things up so that
	cat "${"
does what ought to be done by
	cat "$@"

The advantage of doing this:  if a
	cat "${"
script is run on an "old" shell, you'll get a
	bad substition
error rather than getting the incorrect results.
The "old" shell will have recognized that you've asked it to do something
it doesn't know how to do.
--
	UUCP: ..decvax!seismo!elsie!ado   ARPA: elsie!ado at seismo.ARPA
	DEC, VAX, Elsie & Ado are Digital, Borden & Ampex trademarks.



More information about the Comp.unix.questions mailing list