Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: 'K' subscript flag with associative array?
- X-seq: zsh-workers 28830
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: gak@xxxxxxxxxxxxxx
- Subject: Re: 'K' subscript flag with associative array?
- Date: Tue, 1 Mar 2011 18:09:20 +0100
- Cc: Zsh list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=UIbdRDzPjio2LdwGWsUsxxZ0zLPZ0EzkPFQ85slzgxY=; b=LwGXUNtiYDoy/bleIF43U+y77Iwp6yN2H6Y01AhcAIvxjTG0rdMp4bSeCjtMIJv5vN h18G8pQi100v8/NitXuwyd0qvmZofgl23DkZFWWxwsXRHGm2G4/7EG9zzvt8uYW+19Dz 7DTcvJzaB/w3BMqgzlJvziUvgFcD4WckJ++hc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Rg5jtznDoxL3Z/faBhrIaJ+/2x9BMG+3q59zjvyRooAdd6Hyot4+rGAVomkG7lL1Kz vO6iAyozI80MCim8YQRg06A3Qdhb/VKqVUb1h4y92KIgCYfSlfiS3+DiVr7Oc6t8GK4I SaHG1XESyMESpYes7zVlojkUoEyM3bkErK8zs=
- In-reply-to: <19821.9197.225140.311873@gargle.gargle.HOWL>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <19821.9197.225140.311873@gargle.gargle.HOWL>
On 1 March 2011 17:50, Greg Klanderman <gak@xxxxxxxxxxxxxx> wrote:
>
> Hi guys, what am I doing wrong here? Shouldn't this:
>
> zsh% echo ${(k)functions[(K)_*]}
>
> give all function names starting with '_'?
>
> It gives me nothing; the 'R' subscript flag does seem
> to work for matching against the bodies of functions
> and returning the names of those functions.
>
> thanks,
> Greg
>
% echo ${(k)functions[(<tab>
---- subscript flags
I -- all keys matched by subscript as pattern
K -- all values where subscript matched by key as pattern
R -- all values matched by subscript as pattern
e -- interpret * or @ as a single key
i -- any one key matched by subscript as pattern
k -- any one value where subscript matched by key as pattern
r -- any one value matched by subscript as pattern
Ie, you want I, not K. What K/k does is somewhat weird, in that it
interprets the keys of the arrays as patterns and check which of those
match the given subscript. With I/i you don't need to specify ${(k)
either, it defaults to showing the keys, but you can give ${(v) to
instead get the values.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author