From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10392 invoked from network); 11 Feb 2006 04:16:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 Feb 2006 04:16:00 -0000 Received: (qmail 94638 invoked from network); 11 Feb 2006 04:15:54 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Feb 2006 04:15:54 -0000 Received: (qmail 6127 invoked by alias); 11 Feb 2006 04:15:47 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9911 Received: (qmail 6115 invoked from network); 11 Feb 2006 04:15:47 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 11 Feb 2006 04:15:47 -0000 Received: (qmail 93622 invoked from network); 11 Feb 2006 04:15:46 -0000 Received: from wizard.cse.nd.edu (HELO cse.nd.edu) (129.74.152.2) by a.mx.sunsite.dk with SMTP; 11 Feb 2006 04:15:46 -0000 Received: from cse.nd.edu (cse.nd.edu [129.74.152.2]) by cse.nd.edu (8.13.4/8.13.4) with ESMTP id k1B4Ff76001628 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Fri, 10 Feb 2006 23:15:41 -0500 (EST) Received: from localhost (jwozniak@localhost) by cse.nd.edu (8.13.4/8.12.10/Submit) with ESMTP id k1B4FfRp001624 for ; Fri, 10 Feb 2006 23:15:41 -0500 (EST) Date: Fri, 10 Feb 2006 23:15:41 -0500 (EST) From: Justin M Wozniak To: zsh-users@sunsite.dk Subject: Re: print entire array *with* subscript? In-Reply-To: Message-ID: References: <20060210175012.GA10021@princo> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-CSE-MTA-Date: Fri, 10 Feb 2006 23:15:43 -0500 (EST) X-CSE-Virus-Scan: engine v4.4.00; dat v4694 X-CSE-SpamScan: SpamAssassin 3.001000 X-Scanned-By: MIMEDefang 2.55 on 129.74.152.2 In your solution, what is the point of (r) ? -- Justin Michael Joseph Wozniak On Fri, 10 Feb 2006, Peter Stephenson wrote: > Jean-Rene David wrote: > > It would be nice to be able to do this: > > > > print ${(k)files} > > 1 foo.h 2 foo.c 3 bar.h 4 bar.c > > > > instead of: > > > > for f in {1..$#files}; do > > print $f ${files[$f]}; > > done > > > > Not a big deal. Just asking because that's what I > > thought the documentation meant. > > I think the documentation for the (k) flag is (for once) reasonably > clear and accurate: > > k If name refers to an associative array, substitute the keys > (element names) rather than the values of the elements. Used > with subscripts (including ordinary arrays), force indices or > keys to be substituted even if the subscript form refers to val- > ues. However, this flag may not be combined with subscript > ranges. > > This means you can use it with normal arrays, but only with individual > indices. So: > > % print ${(k)files[(r)foo.c]} > 2 > > but it doesn't work with a subscript nor with a range nor with the * > and @ subscripts (which are special ranges). > > That doesn't mean this is convenient... > >