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 14349
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Simplest way to choose one of several commands
- Date: Mon, 07 Sep 2009 15:32:50 -0700
- In-reply-to: <237967ef0909071449w1c7cdadblb615d61bfc90c235@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <dbfc82860909070922u19535071v17842f1f10ffed4@xxxxxxxxxxxxxx> <ed7b1c610909071433u6e154903ye3b13eeef1894f49@xxxxxxxxxxxxxx> <237967ef0909071449w1c7cdadblb615d61bfc90c235@xxxxxxxxxxxxxx>
On Sep 7, 11:49pm, Mikael Magnusson wrote:
}
} Some meandering through the man page later:
} % echo ${${:-$commands[(R)*/(ls|cat)]}[1]}
} /bin/ls
} % echo ${${:-$commands[(R)*/(ls|cat)]}[2]}
} /bin/cat
I'm not certain that the results are guaranteed to be in the order
that words appear in the (...|...) expression. $commands is a hash
table so I believe the order is going to be unspecified.
} 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)]}.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author