From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19837 invoked by alias); 24 Sep 2017 11:48:21 -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: 41753 Received: (qmail 28276 invoked by uid 1010); 24 Sep 2017 11:48:21 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-2.6/5.0):. Processed in 1.128938 secs); 24 Sep 2017 11:48:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=U1jUyk Q5REMsF6DyVzimNtWo0dntVp38KTYRF2CjnQg=; b=rUVE8A6TsBVoI3JUzeRBkP p7pl8JGtCd9KqE8XHqShhnkhPwvZjiHSWlRdYmzxaQjoy8c/AZkufrO8QFPzhnVl UXroDlYSReN+lvFoOPImWKeAqN9m/l7m/VW7cSkKOor5XrjYlyHo5HRkZTvJVuZm GF4q4IFDOu+h514NOq3i0cK78kFQ+BPgeX44vZTYyN8YX+5PcDb0xI9VxkNOhHQ/ D1uHjxBTi1MOa4MSd24bzTaj5wiIweK6gWlnhypnXybVK9xA0SKk+bHgb0n6cPke 6n2vlBtyBJ1ASELWLIIIRrS6t37qoNA15MUyr5GRFYn9PJpfcSpfVypTJt6do5Bw == DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=U1jUyk Q5REMsF6DyVzimNtWo0dntVp38KTYRF2CjnQg=; b=ZHKIEAcQ/7GAS3GdD97NfS vmRxh983IkOwJUVjfXUe5T22KmC343L1Dp6XRv+DQ7HIViSlDu5sVfJ195XX5nHH 4oB06xRQdPnfEUDwgJsh0z7GY8fID6UVealxRkkJ2grLsB+T0MrHdBYf7p9XF5iQ a0PZMXEgipiAWClVcVDkWwF/E/pXV0cvDGJwilVuNlzZ7Qc/ptNc+2FtPQcwuzqM LhmtQNjKVr9DT5VkOQ3O98rBNhrS/qwZAgYpRLoxVFtyKwVHRu+ZMAdEzvNKRBpB XK8rTb2C+6vAoun5WCOmWwEyxAJN6FglwpAhP+JF8jnkNWm3LpIDTrIw6Z8/oQhg == X-ME-Sender: Message-Id: <1506253077.3028310.1116382488.282AD66D@webmail.messagingengine.com> From: Daniel Shahaf To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-64b08692 Subject: Re: Memory leak when working with undefined associative array keys & problems with unset References: <170917161514.ZM21068@torch.brasslantern.com> <20170923185958.7bddbd39@ntlworld.com> <170923184844.ZM10721@torch.brasslantern.com> In-Reply-To: <170923184844.ZM10721@torch.brasslantern.com> Date: Sun, 24 Sep 2017 11:37:57 +0000 Bart Schaefer wrote on Sat, 23 Sep 2017 18:48 -0700: > On Sep 23, 6:59pm, Peter Stephenson wrote: > } > } $ unset "a[$key]" > } > } unset: a[hello * [ world]: invalid parameter name > } > > } > Hmm, when examining ${a[$key]} we enter parse_subscript() with $key > } > tokenized, but there's no way to get the tokenized string to reach > } > the same point in the unset builtin > } > } I gave up on this ages ago, frankly. We certainly a need way of raw key > } reference, but I don't think we've got one, and each time we tweak it we > } seem to make it even more tortuous. > > The basic problem is that a[$key]=foo is parsed in assignment context, > but unset a[$key] is parsed in ordinary word context. I don't see any > way around this other than either making unset a keyword, or adding a > command-line option to unset as Daniel suggested. Neither of these > alternatives makes me very happy. We could also invent a separate builtin, "zunset". That way we avoid stomping on any options POSIX's 'unset' might grow in the future. This way, scalars, which are standard, are unset by 'unset' which too is standard, and assocs, which are non-standard, are unset by 'zunset' which too is non-standard. > As noted, ksh93 has (had?) also thrown up its hands on this one.