From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20215 invoked by alias); 13 Dec 2015 18:33:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37399 Received: (qmail 29710 invoked from network); 13 Dec 2015 18:33:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Originating-IP: [86.6.158.222] X-Spam: 0 X-Authority: v=2.1 cv=Sd8KDalu c=1 sm=1 tr=0 a=2SBOh4l1h08DI0L+aujZyQ==:117 a=2SBOh4l1h08DI0L+aujZyQ==:17 a=NLZqzBF-AAAA:8 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=zkykuvYJIn2yVr156TYA:9 a=CjuIK1q_8ugA:10 Date: Sun, 13 Dec 2015 18:28:10 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Word splitting/joining inside [[ ]] Message-ID: <20151213182810.158a935e@ntlworld.com> In-Reply-To: <151211203147.ZM4122@torch.brasslantern.com> References: <151211203147.ZM4122@torch.brasslantern.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 11 Dec 2015 20:31:47 -0800 Bart Schaefer wrote: > [[ $words = ${(on)=words} ]] > > Doesn't work. It's always true. Confused, I setopt xtrace and discover: >>> > By accident I discovered that adding a supposedly-meaningless extra level > of nested expansion makes it work: > > torch% [[ $words = ${${(on)=words}} ]] > +zsh:12> [[ 'I have a string of words' == a\ have\ I\ of\ string\ words ]] > > What's going on here? I guess this is something to do with the effect of singsub() and the PREFORK_SINGLE flag which propagates into paramsubst() but not further into multsub() which handles nested expansion. There are likely to be lots of combinations of effects like this that have never been thought through. In particular, forcing single substitution at the top level inhibits various things happening (sometimes even if you've explicitly indicated an affect that would later undo them) whereas the combination of multsub and a paramsubst on top of it is smarter about trying to work out the end effect. So in your second case multsub produces array behaviour which the top level paramsubst can then rationalise back down to a single expression, while in your first case there's no leeway for array behaviour at any point. I don't have any ideas about easy ways to improve singsub. It looks a potential minefield. pws