From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12640 invoked from network); 10 Feb 2006 17:50:35 -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; 10 Feb 2006 17:50:35 -0000 Received: (qmail 2919 invoked from network); 10 Feb 2006 17:50:25 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Feb 2006 17:50:25 -0000 Received: (qmail 16216 invoked by alias); 10 Feb 2006 17:50:16 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9902 Received: (qmail 16204 invoked from network); 10 Feb 2006 17:50:15 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Feb 2006 17:50:15 -0000 Received: (qmail 1801 invoked from network); 10 Feb 2006 17:50:15 -0000 Received: from mx2.magma.ca (206.191.0.250) by a.mx.sunsite.dk with SMTP; 10 Feb 2006 17:50:14 -0000 Received: from mail1.magma.ca (mail1.magma.ca [206.191.0.252]) by mx2.magma.ca (8.13.0/8.13.0) with ESMTP id k1AHoCN5004519 for ; Fri, 10 Feb 2006 12:50:13 -0500 Received: from princo.homelinux.org (ottawa-hs-64-26-167-176.d-ip.magma.ca [64.26.167.176]) by mail1.magma.ca (8.13.0/8.13.0) with ESMTP id k1AHoB8A029342 for ; Fri, 10 Feb 2006 12:50:12 -0500 Received: from jrdavid by princo.homelinux.org with local (Exim 3.36 #1 (Debian)) id 1F7cPM-0002sx-00 for ; Fri, 10 Feb 2006 12:50:12 -0500 Date: Fri, 10 Feb 2006 12:50:12 -0500 From: Jean-Rene David To: zsh-users@sunsite.dk Subject: Re: print entire array *with* subscript? Message-ID: <20060210175012.GA10021@princo> Mail-Followup-To: zsh-users@sunsite.dk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <200602101756.59858.arvidjaar@mail.ru> User-Agent: Mutt/1.5.9i * Andrey Borzenkov : > but I really fail to see when it can be useful. After all to print all array > indices (ignoring KSH_ARRAYS for the moment): > > {pts/0}% echo {1..$#foo} > 1 2 3 The usefulness is a little more obvious when printing both indices and values. The original idea was this. Suppose I have a list of files in an array and I want to select one to do a command on. files=(foo.h foo.c bar.h bar.c) 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. Now that I wrote all this I realize I could just use 'select'... -- JR