Path: utzoo!utgpu!attcan!uunet!nih-csl!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: comp.unix.wizards Subject: Re: Is this known to unix.wizards? Summary: Earliest reference Message-ID: <8604@elsie.UUCP> Date: 7 Jan 89 01:14:53 GMT References: <13307@ncoast.UUCP> Organization: NIH-LEC, Bethesda, MD Lines: 47 In article <13307@ncoast.UUCP>, allbery@ncoast.UUCP (Brandon S. Allbery) writes: > Every so often there is mention of /bin/sh's braindamaged handling of "$@" > when there are no arguments. I think I've worked out a way around it that > doesn't require "if" or "case": > ${1+"$@"} > . . .I find it hard to believe that I'm the first one to notice this, > but I've never seen any discussion of it anywhere and it *certainly* > isn't in the manual or in any of the shell books I've read. I've attached the earliest mention of the idiom that I can find; I don't recall how I first learned of it, but it's used in a number of scripts here at elsie now (sccs work and carbon dating show December of '86 as the earliest occurrence). Thanks to David Giacomo (or whomever) for the discovery! -- UNIX is a registered trademark of AT&T. -- Arthur David Olson ado@ncifcrf.gov ADO is a trademark of Ampex. < Path: elsie!cvl!umcp-cs!seismo!ut-sally!pyramid!decwrl!sun!david < From: david@sun.uucp (David DiGiacomo) < Newsgroups: net.unix-wizards < Subject: Re: Problems with System V Release 2.1 on 68010 < Message-ID: <3514@sun.uucp> < Date: 16 Apr 86 18:15:14 GMT < References: <401@oscvax.UUCP> <412@hropus.UUCP> < Reply-To: david@sun.uUCp (David DiGiacomo) < Organization: Sun Microsystems, Inc. < Lines: 18 < < In article <412@hropus.UUCP> ka@hropus.UUCP (Kenneth Almquist) writes: < >> 4) Is it true that the sh construct "$@" (in a shell script) is supposed < >> to be identically equal to the command-line arguments? It seems that < >> it should, because otherwise there is no way to get at these because < >> $@ = $* gets reparsed, and "$*" is one word. < >> In our sh, "$@" is exactly equivalent to the command line args if there < >> are some, otherwise it is equal to "" instead of nothing. < >> Seems like a bug to me. If so, how wide-spread is it? < > < >It's on our SVR2 on a VAX here. The Korn shell gets this right, of course. < < This also afflicts SunOS 3.0. I find it incredibly annoying, but a simple < workaround is to use ${1+"$@"} instead of plain "$@". < < [disclaimer] < -- < David DiGiacomo {decvax, ihnp4, ucbvax}!sun!david david@sun.arpa < Sun Microsystems, Mt. View, CA (415) 960-7495