Is this known to unix.wizards?

Leo de Wit leo at philmds.UUCP
Fri Jan 6 15:54:51 AEST 1989


In article <13307 at ncoast.UUCP> allbery at 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+"$@"}
|
|The above construct should NOT be quoted.  And I'm pretty sure it will work
|on all versions of the Bourne shell.  It seems to work in some tests I've
|done here.  Anyone else want to comment?  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.

In article <15232 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
   [Subject: Re: make bug]
|echo ${1+"$@"} | sed -e "s/ /$suf /g" -e "s/$/$suf/"
   and
|echo ${1+"$@"} | sed -e "s/$oldsuf /$newsuf /g" -e "s/$oldsuf$/$newsuf/"

so at least Chris knew of the construct (or hacked up his scripts
quickly after seeing Brandon's message 8-).

                                              Leo.



More information about the Comp.unix.wizards mailing list