From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20158 invoked by alias); 22 Feb 2012 20:19:53 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30257 Received: (qmail 167 invoked from network); 22 Feb 2012 20:19:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 74.125.82.171 is neither permitted nor denied by SPF record at ntlworld.com) Received-SPF: pass (google.com: domain of p.w.stephenson@ntlworld.com designates 10.216.132.32 as permitted sender) client-ip=10.216.132.32; Authentication-Results: mr.google.com; spf=pass (google.com: domain of p.w.stephenson@ntlworld.com designates 10.216.132.32 as permitted sender) smtp.mail=p.w.stephenson@ntlworld.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=gamma; h=x-proxyuser-ip:date:from:to:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=4kZ5wgDeNgSS65cEhnZqJWz4yeoVOqKCksmHt6DXToQ=; b=x+QJw51tzjD3Iy1EVGFPvTd5ccHyVQX061WtJcNmgrWQtBX9r1YSb8yS2CuxSZyd8y CZlIQD6kNtnIrbBH/WSHVD2P+hXpYy+R8HCyF0/t2QUzwbfg3OgesAIO/XrS/3gmgSjb uRzhqmqiWD5i6vJnED9Q+J7QhsesBHuP/fxkM= X-ProxyUser-IP: 86.6.29.42 Date: Wed, 22 Feb 2012 20:19:39 +0000 From: Peter Stephenson To: Subject: Re: let unset array element remove compatible with bash Message-ID: <20120222201939.53899980@pws-pc.ntlworld.com> In-Reply-To: <120222092827.ZM24425@torch.brasslantern.com> References: <120221210106.ZM13374@torch.brasslantern.com> <20120222095248.1ea8140b@pwslap01u.europe.root.pri> <120222092827.ZM24425@torch.brasslantern.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQmsqqmBnAVJLfhuc8p6DVpDSjIaHKUqXq+nUc50RgruHImJ1f2PIzhA7eP0v7Dmbh67yzkE On Wed, 22 Feb 2012 09:28:27 -0800 Bart Schaefer wrote: > On Feb 22, 9:52am, Peter Stephenson wrote: > } > } So it's not simply a case of unconditionally deleting an element. I > } think you need to check the element is present in the first place. > > Is there a straightforward way to do that? The code in subst.c that > handles ${+var[x]} is rather convoluted, and every combination of > getvalue()/fetchvalue() that I've tried always returns non-NULL for > subscripted expressions. At this level, I'd have thought it was good enough to test the length of the array directly. However, you can only do that after you've evaluated the subscript, so it probably needs some poking down into params.c first. Presumably if you're trying to unset an element of the array, retrieving it isn't likely to be difficult. > Gaah. Didn't I say that? -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/