Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Memory leak when working with undefined associative array keys & problems with unset
- X-seq: zsh-workers 41753
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Memory leak when working with undefined associative array keys & problems with unset
- Date: Sun, 24 Sep 2017 11:37:57 +0000
- 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 ==
- In-reply-to: <170923184844.ZM10721@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <VI1PR0501MB23514D1D7839FDF243840C91D76D0@VI1PR0501MB2351.eurprd05.prod.outlook.com> <170917161514.ZM21068@torch.brasslantern.com> <20170923185958.7bddbd39@ntlworld.com> <170923184844.ZM10721@torch.brasslantern.com>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author