From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17819 invoked from network); 12 Feb 2001 19:39:07 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 12 Feb 2001 19:39:07 -0000 Received: (qmail 16886 invoked by alias); 12 Feb 2001 19:38:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13455 Received: (qmail 16875 invoked from network); 12 Feb 2001 19:38:56 -0000 From: "Bart Schaefer" Message-Id: <1010212193848.ZM23715@candle.brasslantern.com> Date: Mon, 12 Feb 2001 19:38:48 +0000 In-Reply-To: <000901c094c6$d2bcd500$21c9ca95@mow.siemens.ru> Comments: In reply to "Andrej Borsenkow" "RE: PATCH: 3.1.9-dev-8: Re: Word splitting in zsh" (Feb 12, 10:38am) References: <000901c094c6$d2bcd500$21c9ca95@mow.siemens.ru> <002701c094fd$d7680890$21c9ca95@mow.siemens.ru> In-Reply-To: <002701c094fd$d7680890$21c9ca95@mow.siemens.ru> Comments: In reply to "Andrej Borsenkow" "RE: PATCH: 3.1.9-dev-8: Re: Word splitting in zsh" (Feb 12, 5:12pm) X-Mailer: Z-Mail (5.0.0 30July97) To: Subject: Re: PATCH: 3.1.9-dev-8: Re: Word splitting in zsh MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Feb 12, 10:38am, Andrej Borsenkow wrote: } } > This applies only to ${...+...} and ${...-...}, with or without the `:'. } > As I mentioned, there would be some benefit to also doing this for the } > ${...=...} forms, because then things like ${(A)foo="$bar[@]"} would work } > independently of the setting of shwordplit. } > } } Is the following a bug in shell and should zsh emulate it? } } bor@itsrm2% sh } $ set "a b c" 1 2 } $ args ${foo="$@"} } 3 } a b c } 1 } 2 Bash seems to emulate it. } In case of ${name-word} or ${name+word} sh does exactly *one* expansion (as } opposed to zsh that does two) That's not precisely what's happening in zsh. It does only one expansion, but it does word splitting based on the outer (lack of) quotes rather than the inner ones. Which I suppose could be called "two expansions" ... The equivalent of the patch that I made for ${x+y} and ${x-y}, applied to ${x=y}, would have the effect of emulating the above behavior. On Feb 12, 5:12pm, Andrej Borsenkow wrote: } Subject: RE: PATCH: 3.1.9-dev-8: Re: Word splitting in zsh } } And is this a bug or feature in zsh (with Bart's patch): Note that my patch makes absolutely no difference to this; read the very first double-excerpted paragraph above. } bor@itsrm2% baz=("aa bb" cc) } bor@itsrm2% print -l "${(A)foo=$baz[@]}" } aa bb } cc } bor@itsrm2% print -l "${(A)foo=$baz[@]}" } aa bb cc } } both cases should evaluate to the value of $foo, if I read specs } properly, and be identical, i.e. as in the second case. This is a slightly different bug; what's interesting is how bash handles it ... note the difference between ${x+y} and ${x=y}: [schaefer@zagzig schaefer]$ set "a1 a2 a3" b c [schaefer@zagzig schaefer]$ for i in "${1+$@}"; do echo "$i"; done a1 a2 a3 b c [schaefer@zagzig schaefer]$ for i in "${foo=$@}"; do echo "$i"; done a1 a2 a3 b c [schaefer@zagzig schaefer]$ for i in "${foo+$@}"; do echo "$i"; done a1 a2 a3 b c To "fix" this in zsh is trivial, if we want it fixed; just copy some code from above the "Check for ${..?..} or ${..=..} or one of those." block: Index: Src/subst.c =================================================================== --- Src/subst.c 2001/02/10 20:33:32 1.73 +++ Src/subst.c 2001/02/12 19:22:18 @@ -1454,6 +1454,14 @@ } *idend = sav; copied = 1; + if (isarr) { + if (nojoin) + isarr = -1; + if (qt && !getlen && isarr > 0) { + val = sepjoin(aval, sep, 1); + isarr = 0; + } + } } break; case '?': -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net