Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Example function
- X-seq: zsh-workers 5038
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>, Phil Pennock <comet@xxxxxxxx>, Zsh Development Workers <zsh-workers@xxxxxxxxxxxxxx>
- Subject: Re: Example function
- Date: Tue, 26 Jan 1999 16:37:43 -0800
- In-reply-to: <990126162520.ZM25560@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <19990126184200.B27794@xxxxxxxx> <990126162520.ZM25560@xxxxxxxxxxxxxxxxxxxxxxx>
On Jan 26, 4:25pm, Bart Schaefer wrote:
> Subject: Re: Example function
> (One of the things on the associative-array wishlist is "reverse pattern"
> lookup, that is, treat the array keys as patterns and match them against
> the subscript. Then you could do silly stuff like
>
> typeset -A map
> map=('*.(gz|Z)' zcat
> '*.bz2' 'bzip2 -dc'
> '*.bz' 'bzip -dc'
> '*' '<')
> eval ${(q)map[$argv[i]]} '$argv[i]'
>
> where I'm using (q) as the fictional reverse-pattern query flag; probably
> there's a better letter.)
Incidentally, the reason this isn't there already is that associative arrays
are unordered hashes, so you can't predict _which_ pattern will match the
subscript when you do the query -- '*' might match before '*.bz' is tried.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author