From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26760 invoked from network); 16 Mar 2008 18:48:24 -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 18:48:24 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 5878 invoked from network); 16 Mar 2008 18:48:19 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 16 Mar 2008 18:48:19 -0000 Received: (qmail 8360 invoked by alias); 16 Mar 2008 18:48:16 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24719 Received: (qmail 8342 invoked from network); 16 Mar 2008 18:48:15 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 16 Mar 2008 18:48:15 -0000 Received: from vms173001pub.verizon.net (vms173001pub.verizon.net [206.46.173.1]) by bifrost.dotsrc.org (Postfix) with ESMTP id C91EE80307F7 for ; Sun, 16 Mar 2008 19:48:11 +0100 (CET) Received: from torch.brasslantern.com ([71.116.105.150]) by vms173001.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JXU004HV6CBG28I@vms173001.mailsrvcs.net> for zsh-workers@sunsite.dk; Sun, 16 Mar 2008 13:36:12 -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 m2GIllTa010132 for ; Sun, 16 Mar 2008 11:47:47 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id m2GIllZH010131 for zsh-workers@sunsite.dk; Sun, 16 Mar 2008 11:47:47 -0700 Date: Sun, 16 Mar 2008 11:47:47 -0700 From: Bart Schaefer Subject: Re: ${a[(i)pattern]} if a=() In-reply-to: <080316105924.ZM843@torch.brasslantern.com> To: Zsh hackers list Message-id: <080316114747.ZM10130@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> <080316102021.ZM28339@torch.brasslantern.com> <080316105924.ZM843@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: ${a[(i)pattern]} if a=()" (Mar 16, 10:59am) X-Virus-Scanned: ClamAV 0.91.2/6264/Sun Mar 16 18:29:00 2008 on bifrost X-Virus-Status: Clean On Mar 16, 10:59am, Bart Schaefer wrote: } } The patch is trivial and all tests still pass. Here's a test for that patch. Also fixes the previous test which declared an empty array but then referenced an undefined variable. Or at least I think what I changed is what the test really meant. I won't commit this (or 24718) without some confirmation. Index: Tests/D06subscript.ztst =================================================================== --- Tests/D06subscript.ztst 26 Nov 2007 17:38:14 -0000 1.8 +++ Tests/D06subscript.ztst 16 Mar 2008 18:44:20 -0000 @@ -178,11 +178,15 @@ >lower >upper - typeset -a empty_array - echo X${${l##*}[-1]}X + typeset -ga empty + echo X${${empty##*}[-1]}X 0:Negative index applied to substition result from empty array >XX + print $empty[(i)] $empty[(I)] +0:(i) returns 1 for empty array, (I) returns 0. +>1 0 + array=(one two three four) print X$array[0]X 0:Element zero is empty if KSH_ZERO_SUBSCRIPT is off.