From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15208 invoked by alias); 26 Mar 2017 19:41:53 -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: 40902 Received: (qmail 19800 invoked from network); 26 Mar 2017 19:41:53 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-6.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.70):SA:0(-2.8/5.0):. Processed in 0.995108 secs); 26 Mar 2017 19:41:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.70 as permitted sender) X-Originating-IP: [86.21.219.59] X-Spam: 0 X-Authority: v=2.1 cv=H94muLsi c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=MWUjAzoEKyAA:10 a=W4zOZ-njeoZCshi-85wA:9 a=CjuIK1q_8ugA:10 Date: Sun, 26 Mar 2017 20:34:46 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: get keys of an associative array? Message-ID: <20170326203446.45f5883e@ntlworld.com> In-Reply-To: <20170326191828.GA13089@trex.cs.ovgu.de> References: <20170326191828.GA13089@trex.cs.ovgu.de> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 26 Mar 2017 21:18:28 +0200 Jens Elkner wrote: > I've KSH_ARRAYS (beside KSH_GLOB KSH_TYPESET KSH_OPTION_PRINT) set, > however, getting the key set of an array via ${!vname[@]} (as usually > done within ksh or bash) does not work (bad substitution). That's never been implemented; it may be too far away from how zsh works to do usefullly. > Couldn't find anything else, except the @k flag, but this doesn't work > as well, e.g. > > unset A; typeset -A A; A['a']=1; A['b']=2; A['c']=3 ; print "${(@k)A}" > > should print 'a b c' but prints '3'. Bug, feature? Hmmm, any hints? You need "${(k)A[@]}" in ksh mode, but I'm not sure why the (@) flag doesn't do the trick. As it's an associative array you get the keys back unordered. pws