Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Simplest way to choose one of several commands
- X-seq: zsh-users 14354
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Simplest way to choose one of several commands
- Date: Tue, 8 Sep 2009 20:02:22 +0100
- In-reply-to: <090907153250.ZM6506@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <dbfc82860909070922u19535071v17842f1f10ffed4@xxxxxxxxxxxxxx> <ed7b1c610909071433u6e154903ye3b13eeef1894f49@xxxxxxxxxxxxxx> <237967ef0909071449w1c7cdadblb615d61bfc90c235@xxxxxxxxxxxxxx> <090907153250.ZM6506@xxxxxxxxxxxxxxxxxxxxxx>
On Mon, 07 Sep 2009 15:32:50 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> } Side note, I would have expected $commands[(K)(ls|cat)] to list
> } /bin/ls and /bin/cat, but it doesn't (it's empty).
>
> That does seem odd, but you can get it with ${(v)commands[(I)(ls|cat)]}.
They're different. (K) treats the *keys* as patterns (there's a clue
there), and matches them against the index argument.
% typeset -A foo
% foo=('(ls|gls)' "This is the one you want")
% print ${foo[(K)ls]}
This is the one you want
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author