Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug Report: Variable becomes unset without reason
- X-seq: zsh-workers 44665
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: Bug Report: Variable becomes unset without reason
- Date: Wed, 14 Aug 2019 17:12:19 +0200
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CBbhzT72AnDYvSXyhLB9x7EDksMnbX01yNGLTnNfpf8=; b=rrLky2JSmBtRDftsIFOJh8TMw2zqfai3XyxKPk8mURfYuVpMa1YtYykqxcP5z4pF0D L2iGH4kzkWk4kT8S0iKpSyOGqVq/ZNrwlHxC4Qqkeeg8kk39tPOYF/GZjBB5cOZpQ//0 mjx0d/JCZT7B0jNd2I5n7nxf1YiSc2tWa+J3Sd76QcbKKVLGlKc3NyDCxz6kIMs5EyzY hF4MWW2ESileis2IhzjvOy+n2ITaSB9D4I/KiUqxlQb6kIgMjWIDhM3ukDZk8Ermg9u+ 41HIGxiMHg/OXTAwZbwkTzrDuISMQJR/AXb1JyRSLdVmT2V9ftY04i5YQwhpQ665ixen Xpwg==
- In-reply-to: <1565791473.4796.6.camel@samsung.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>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <2154283D-97B8-436B-8CC5-40624C11F356@icloud.com> <CGME20190814093844epcas2p44f875d2a2dd79067539d55e34fed4ae2@epcas2p4.samsung.com> <20190814093748.u3pkdzrixmtunnt7@chaz.gmail.com> <1565791473.4796.6.camel@samsung.com>
On 8/14/19, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> On Wed, 2019-08-14 at 10:37 +0100, Stephane Chazelas wrote:
>> 2019-08-08 20:38:05 +0430, Aryn Starr:
>> Now, that being said, as discussed on U&L it looks like a bug
>> indeed and a shorter reproducer is:
>>
>> $ zsh -xc 'v=1; f() { local v; v=2 true; }; f; typeset -p v'
>> +zsh:1> v=1
>> +zsh:1> f
>> +f:0> local v
>> +f:0> v=2 +f:0> true
>> +zsh:1> typeset -p v
>> zsh:typeset:1: no such variable: v
>>
>> Most likely, that's the "v=2 true" (where "true" is a builtin) that ends
>> up
>> unsetting the "v" from the global scope.
>
> Yes, the saved version of "v" that we restore after the builtin is
> missing the pointer back to the version of v in the enclosing scope. So
> it's not only not shown as set, it will leak memory.
>
> This simply preserves that pointer in the copy, but this assumes we've
> correctly blocked off the old parameter from being altered inside the
> function scope --- if we haven't that preserved old pointer is going to
> get us into trouble. However, if we haven't that's already a bug, so
> this shouldn't make things worse.
This got me thinking about related stuff. I guess these results are
expected, maybe even at best unspecified?
% foo=initial; foo=bar printf -v foo hello; echo $foo
initial
% set hi; argv= set hello; echo $1
hi
% set a b c; argv= shift; echo $@
a b c
% a=1; a=5 typeset a=3 b=7; echo $a$b
17
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author