From: "Benjamin R. Haskell" <zsh@benizi.com>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Expand array into multiple elements per item?
Date: Tue, 13 Sep 2011 13:32:24 -0400 (EDT) [thread overview]
Message-ID: <alpine.LNX.2.01.1109131322150.10525@hp.internal> (raw)
In-Reply-To: <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
> A/02_something B/03_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 :).
+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
next prev parent reply other threads:[~2011-09-13 17:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-13 8:15 Benjamin R. Haskell
2011-09-13 8:36 ` Anthony Charles
2011-09-13 8:52 ` Benjamin R. Haskell
2011-09-15 18:07 ` Oliver Kiddle
2011-09-13 8:57 ` Peter Stephenson
2011-09-13 10:19 ` Mikael Magnusson
2011-09-13 17:32 ` Benjamin R. Haskell [this message]
2011-09-13 17:21 ` Benjamin R. Haskell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.01.1109131322150.10525@hp.internal \
--to=zsh@benizi.com \
--cc=mikachu@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).