From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1606 invoked by alias); 13 Sep 2011 08:57:20 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16335 Received: (qmail 9571 invoked from network); 13 Sep 2011 08:57:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Tue, 13 Sep 2011 09:57:07 +0100 From: Peter Stephenson To: Zsh Users Subject: Re: Expand array into multiple elements per item? Message-ID: <20110913095707.28e2d2d1@pwslap01u.europe.root.pri> In-Reply-To: References: Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.103.10.104] X-Scanned-By: MailControl A-12-01-02 (www.mailcontrol.com) on 10.68.0.112 On Tue, 13 Sep 2011 04:15:50 -0400 "Benjamin R. Haskell" wrote: > Three questions: > > 1. How can I easily take: > > somelist=( 'a b' c 'd e' ) > > and get back: > > anotherlist=( -id 'a b' -id c -id 'd e' ) anotherlist=({-id,${^somelist}}) > 2. ...relatedly, I'm confused by the following: > > $ somelist=( 'a b' c 'd e' ) > $ print -l - $somelist > a b > c > d e > (i) $ print -l - $^somelist(e:'reply=( -id $REPLY )':) > zsh: no matches found: a b(e:reply=( -id $REPLY ):) > (ii) $ print -l - $^somelist(Ne:'reply=( -id $REPLY )':) > (...nothing printed...) > $ > > Why does neither (i) nor (ii) work? The main problem is that globbing flags rely on globbing; if there's no matching file, it doesn't work. You'd probably want "oN" in the globbing flags to turn off sorting if you did have files. > 3. I thought I recalled a relatively recent addition to parameter > expansion flags for just this use-case. But I can't seem to find the > flag in zsh-4.3.12 patchlevel 1.5346. Still interested in the answer to > the rest, regardless. You might be thinking of the globbing flag, P. If you did have files, *(P:-id:) would have done what you wanted. But you don't. The actual effect is a bit bizarre (turning off nomatch): -id a b(P:-id:) -id c(P:-id:) -id d e(P:-id:) -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog