From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25271 invoked from network); 8 Oct 2008 05:36:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) 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.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 8 Oct 2008 05:36:30 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 55898 invoked from network); 8 Oct 2008 05:36:19 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 8 Oct 2008 05:36:19 -0000 Received: (qmail 25275 invoked by alias); 8 Oct 2008 05:36:09 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25827 Received: (qmail 25256 invoked from network); 8 Oct 2008 05:36:07 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 8 Oct 2008 05:36:07 -0000 Received: from vms173005pub.verizon.net (vms173005pub.verizon.net [206.46.173.5]) by bifrost.dotsrc.org (Postfix) with ESMTP id A747D80308BD for ; Wed, 8 Oct 2008 07:36:02 +0200 (CEST) Received: from torch.brasslantern.com ([96.238.220.215]) by vms173005.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0K8E0015DNJWFC53@vms173005.mailsrvcs.net> for zsh-workers@sunsite.dk; Wed, 08 Oct 2008 00:35:57 -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 m985ZtFd018219 for ; Tue, 07 Oct 2008 22:35:56 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id m985ZtRZ018218 for zsh-workers@sunsite.dk; Tue, 07 Oct 2008 22:35:55 -0700 Date: Tue, 07 Oct 2008 22:35:53 -0700 From: Bart Schaefer Subject: Baffling array substitution behavior To: zsh-workers@sunsite.dk Message-id: <081007223555.ZM18217@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii X-Virus-Scanned: ClamAV 0.92.1/8394/Wed Oct 8 06:15:25 2008 on bifrost X-Virus-Status: Clean You may have seen the the pids4kill function that I posted to zsh-users a little while ago. When I was first trying it out, I mistook opt_args for a plain array rather than an associative array, so I wrote: local u=$opt_args[(I)-u] Strangely, the entire assignment vanished on parameter substitution, so what was executed was local which naturally was not what I wanted. Turns out this is a side-effect of "setopt rcexpandparam", but is it really an intended side-effect? Test program: rcexbug() { emulate -L zsh setopt rcexpandparam local -A hash local -a full empty full=(X x) hash=(X x) print ORDINARY ARRAYS : The following behaves as documented in zshoptions print FULL expand=$full : The documentation does not discuss this next behavior print EMPTY expand=$empty print ASSOCIATIVE ARRAY print Subscript flags returning many values print FOUND key=$hash[(I)X] val=$hash[(R)x] : This should behave like $empty, and does print LOST key=$hash[(I)y] val=$hash[(R)Y] print Subscript flags returning single values : Doc says "substitutes ... empty string" : but this behaves like an empty array print CONFUSED key=$hash[(i)y] val=$hash[(r)Y] } --