From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3656 invoked from network); 16 Mar 2008 17:20:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 16 Mar 2008 17:20:43 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 61832 invoked from network); 16 Mar 2008 17:20:36 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 16 Mar 2008 17:20:36 -0000 Received: (qmail 8167 invoked by alias); 16 Mar 2008 17:20:33 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24717 Received: (qmail 8154 invoked from network); 16 Mar 2008 17:20:33 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 16 Mar 2008 17:20:33 -0000 Received: from vms173003pub.verizon.net (vms173003pub.verizon.net [206.46.173.3]) by bifrost.dotsrc.org (Postfix) with ESMTP id DA25480307F7 for ; Sun, 16 Mar 2008 18:20:29 +0100 (CET) Received: from torch.brasslantern.com ([71.116.105.150]) by vms173003.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JXU00JQP2P8S5TA@vms173003.mailsrvcs.net> for zsh-workers@sunsite.dk; Sun, 16 Mar 2008 12:17:33 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id m2GHKMsH028341 for ; Sun, 16 Mar 2008 10:20:22 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id m2GHKLne028340 for zsh-workers@sunsite.dk; Sun, 16 Mar 2008 10:20:21 -0700 Date: Sun, 16 Mar 2008 10:20:21 -0700 From: Bart Schaefer Subject: Re: ${a[(i)pattern]} if a=() In-reply-to: <20080316144038.GA4910@sc.homeunix.net> To: Zsh hackers list Message-id: <080316102021.ZM28339@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <20080316144038.GA4910@sc.homeunix.net> Comments: In reply to Stephane Chazelas "${a[(i)pattern]} if a=()" (Mar 16, 2:40pm) X-Virus-Scanned: ClamAV 0.91.2/6261/Sun Mar 16 17:03:51 2008 on bifrost X-Virus-Status: Clean On Mar 16, 2:40pm, Stephane Chazelas wrote: } Subject: ${a[(i)pattern]} if a=() } } Hiya, } } $ zsh -f -c 'a=(b); echo ${a[(i)a]}' } 2 } $ zsh -f -c 'a=(); echo ${a[(i)a]}' } 0 } } Shouldn't the above return 1? Hmm ... it seems it has always returned zero when the array is empty. It would seem to make more sense for it to return 1, but I'm worried there are other unforseen consequences. What changed is zsh-workers/23562, which made it an error to treat a zero subscript the same as 1 (see the thread leading up to 23562 and the related thread ending in 23440). Naturally we had code relying on the old behavior and didn't find all of those cases. } That at leasts causes compinstall to fail The following will work around the above issue to fix that: --- compinstall.~1.11.~ 2008-02-11 20:25:13.000000000 -0800 +++ compinstall 2008-03-16 10:17:55.000000000 -0700 @@ -1438,7 +1438,7 @@ done amenu=(${=menu}) elt=${amenu[(i)*select*]} - [[ $elt -gt $#amenu ]] && elt= + [[ $elt -eq 0 || $elt -gt $#amenu ]] && elt= case $select in <->) if [[ -n $elt ]]; then amenu[$elt]="select=$select"