From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27038 invoked by alias); 1 Mar 2011 17:13:33 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28831 Received: (qmail 20640 invoked from network); 1 Mar 2011 17:13:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Tue, 1 Mar 2011 12:13:02 -0500 (EST) From: "Benjamin R. Haskell" To: Greg Klanderman cc: Zsh list Subject: Re: 'K' subscript flag with associative array? In-Reply-To: <19821.9197.225140.311873@gargle.gargle.HOWL> Message-ID: References: <19821.9197.225140.311873@gargle.gargle.HOWL> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed On Tue, 1 Mar 2011, Greg Klanderman wrote: > > Hi guys, what am I doing wrong here? Shouldn't this: > > zsh% echo ${(k)functions[(K)_*]} > > give all function names starting with '_'? You want: ${functions[(I)_*]} If I'm reading the man page right, I'd interpret your attempt as: the list of functions whose names, when taken as patterns, match the literal string: '_*' K treats the keys as patterns. Most function names don't contain pattern metachars, so when taken as patterns, only match their own names. But, for example: $ '??' () { echo question everything } $ print -l ${(k)functions[(K)_*]} ?? # because the key '??' matches any two characters $ print -l ${(k)functions[(K)lj]} ?? Not sure what the utility is, though. Something like this, I guess? $ typeset -A featureset $ featureset=( '*.*' hasadot 'test.*' 'test function' ) $ print -l ${featureset[(K)lkjlkjljk.ojojojoj]} hasadot $ print -l ${featureset[(K)test.function]} hasadot test function -- Best, Ben