From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27471 invoked by alias); 13 Sep 2011 17:33:04 -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: 16345 Received: (qmail 29422 invoked from network); 13 Sep 2011 17:32:53 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at benizi.com does not designate permitted sender hosts) Date: Tue, 13 Sep 2011 13:32:24 -0400 (EDT) From: "Benjamin R. Haskell" To: Mikael Magnusson cc: Zsh Users Subject: Re: Expand array into multiple elements per item? In-Reply-To: Message-ID: References: <20110913095707.28e2d2d1@pwslap01u.europe.root.pri> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed On Tue, 13 Sep 2011, Mikael Magnusson wrote: > On 13 September 2011 10:57, Peter Stephenson wrote: >>> 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. [...] >> > > One fun thing you can do is use .(e,'reply=(foo bar baz)',) if you > want to use some other globbing flags on your data. It's not > applicable for this problem, at least I can't think of a way. I did > suggest it on irc once for sorting an array by the basename: > > 22:39 I want to sort this by basename so that I order the > elements in this pair of expansions asciibetically regardless of the > directory they're found in. > 22:39 (so, for example, if I had A/02_something > B/01_something B/03_something, it'd come out as B/01_something > A/02_something B/03_something) > 22:47 a=( oneglob anotherglob ) > 22:47 echo .(e:'reply=($a)':oe,'REPLY=$REPLY:t',) > > It would be nice to have a similar mechanism for sorting arrays maybe :). +1. > Oh wait, I just realized it does work, just do this: > > % print -l - .(e:'reply=($somelist)':P:-id:) > -id > a b > -id > c > -id > d e > > Obviously, this does qualify in the 'a bit of a hack' category. (And > yes, it does fail if $PWD is chmoded -x, maybe / is a safer bet.) Cool. Nice hack. -- Best, Ben