[gnu.bash.bug] ${1+"$@"}

maart@cs.vu.nl (Maarten Litmaath) (09/28/89)

chet@cwns1.CWRU.EDU (Chet Ramey) writes:
\In article <8909271448.AA28013@abel.math.uiuc.edu> skl@ABEL.MATH.UIUC.EDU
\(Soren Lundsgaard) writes:
\>There is one bug report which I submitted which is still
\>outstanding:  ${1+"$@"} is not expanded correctly if there is a
\>word with a space in it.
\
\Quoting from the SunOS 4.0 sh man page, which is derived from that of Sys 5
\release 3.1:
\
\"Blank Interpretation
\
\After parameter and command substitution, the results of substitution are
\scanned for internal field separator characters (those found in IFS) and
\split into distinct arguments where such characters are found.  Explicit
\null arguments ("" or '') are retained.  Implicit null arguments (those
\resulting from parameters that have no values) are removed."
\
\This sounds pretty much like what bash is doing.  If you want to preserve
\quotes, quote the whole thing ("${1+$@}").

Sorry Chet, I guess you're wrong here: if I say "$@", do you want the strings
to be broken up into whitespace-separated words?
A quite rhetorical question.
Furthermore "${1+$@}" is completely equivalent to "$@"!
(Think about it before you follow up!)
The classic Bourne shell didn't handle this correctly, so we had to use a
trick to circumvent it: ${1+"$@"}.
I guess bash has got "$@" fixed, but the `trick' must still work as always,
else tons of shell scripts must be fixed.
-- 
 `I AM NEW HEAR AMD I WANT TO INKRIMENT A |Maarten Litmaath @ VU Amsterdam:
 VURIABLE BY 1 (OONE) IN "c"'  (Tom Neff) |maart@cs.vu.nl, mcvax!botter!maart