On Mi, 06 Apr 2016, Ben Boeckel wrote: > On Thu, Apr 07, 2016 at 09:38:43 +1000, Cameron Simpson wrote: > > For historic reasons, "$@" evaluates to a single "" if there were no > > arguments at all, introducing a spurious new empty argument. > > Possibly the thinking was that something like "$@" should never > > vanish; after all "$x" will produce an single empty string if $x is > > empty. The ${1+} simply avoids using "$@" at all unless there are > > arguments, producing correct behaviour in the no-arguments case. > > What shell is that? I've *never* encountered such a bug (well, I'd > classify it as such at this point) and I do quite a bit of shell > scripting.
According to Sven Maschecks website http://www.in-ulm.de/~mascheck/various/bourne_args/ ,---- | These shells behave the old way and need ${1+"$@"}: | | Certainly: /bin/sh on 7th edition (aka Version 7). And thus also /bin/sh on original BSDs, until these shipped the Almquist shell (after 4.3BSD-Reno) | HP-UX 8, 9 /bin/sh, HP-UX 10.x, 11.x /usr/old/bin/sh (as /bin/sh has become a ksh) | OSF1/V4 and V5 aka Tru64 /bin/sh | Ultrix /bin/sh and /bin/sh5 | Sinix 5.20 /bin/sh in both the "ucb" and the "sie" universe `---- so basically, not relevant anymore. regards, Christian -- The Martian landed his saucer in Manhattan, and immediately upon emerging was approached by a panhandler. "Mister," said the man, "can I have a quarter?" The Martian asked, "What's a quarter?" The panhandler thought a minute, brightened, then said, "You're right! Can I have a dollar?"