From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4605 invoked from network); 12 Feb 2001 07:39:05 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 12 Feb 2001 07:39:05 -0000 Received: (qmail 127 invoked by alias); 12 Feb 2001 07:38:49 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13453 Received: (qmail 116 invoked from network); 12 Feb 2001 07:38:48 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer david.siemens.de) From: "Andrej Borsenkow" To: "Bart Schaefer" , "Deborah Ariel Pickett" , Subject: RE: PATCH: 3.1.9-dev-8: Re: Word splitting in zsh Date: Mon, 12 Feb 2001 10:38:42 +0300 Message-ID: <000901c094c6$d2bcd500$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 In-Reply-To: <1010210202412.ZM20301@candle.brasslantern.com> Importance: Normal > > 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 $ args $foo 5 a b c 1 2 Compare with zsh: bor@itsrm2% setopt shwordsplit bor@itsrm2% set "a b c" 1 2 bor@itsrm2% print -l ${foo="$@"} a b c 1 2 To explain what's going on: In case of ${name-word} or ${name+word} sh does exactly *one* expansion (as opposed to zsh that does two) with the pseudocode (e.g. for -) if defined name replace $name else replace expanded word (BTW I was surprised to see that expansions in word actually nest; ${xxx-${yyy-bar}} results in ``bar''). But in case of ${name=bar} the definition is Assign Default Values. If parameter is unset or null, the expansion of word will be assigned to parameter. In all cases, the final value of parameter will be substituted. Only variables, not positional parameters or special parameters, can be assigned in this way. BUT sh has only scalar parameters - so, the "final value" can only be scalar that it then word splitted - as happens in zsh :-) But it looks, like sh behaves as in case of ${...-...}/${...+...} - i.e. it substitutes expansion of word and assigns it to name. It smells like a bug in (our) sh to me. -andrej P.S. Deborah, it's probably becoming way too specific. Should we still Cc you?