Zsh Mailing List Archive
Messages sorted by:
Re: Expand array into multiple elements per item?
- X-seq: zsh-users 16345
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>
- Subject: Re: Expand array into multiple elements per item?
- Date: Tue, 13 Sep 2011 13:32:24 -0400 (EDT)
- Cc: Zsh Users <zsh-users@xxxxxxx>
- In-reply-to: <CAHYJk3RqSJqjHdtu=8yiRBMiSPfxq8OwP9A4cbkCdGydpjefOw@mail.gmail.com>
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <alpine.LNX.email@example.com> <firstname.lastname@example.org> <CAHYJk3RqSJqjHdtu=8yiRBMiSPfxq8OwP9A4cbkCdGydpjefOw@mail.gmail.com>
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 <offbyone> 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 <offbyone> (so, for example, if I had A/02_something
B/01_something B/03_something, it'd come out as B/01_something
22:47 <Mikachu> a=( oneglob anotherglob )
22:47 <Mikachu> echo .(e:'reply=($a)':oe,'REPLY=$REPLY:t',)
It would be nice to have a similar mechanism for sorting arrays maybe :).
Oh wait, I just realized it does work, just do this:
% print -l - .(e:'reply=($somelist)':P:-id:)
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.
Messages sorted by: