Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Fix a WARN_CREATE_GLOBAL false positive.
- X-seq: zsh-workers 32092
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH] Fix a WARN_CREATE_GLOBAL false positive.
- Date: Fri, 06 Dec 2013 09:23:09 +0000
- In-reply-to: <20131206074728.GA2313@tarsus.local2>
- 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
- Organization: Samsung Cambridge Solution Centre
- References: <20131206074728.GA2313@tarsus.local2>
On Fri, 06 Dec 2013 09:47:28 +0200
Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> This seems to be a false positive:
>
> % zsh -fc 'setopt warn_create_global; (){ x=y =true }'
> (anon): scalar parameter x created globally in function
>
> Regression test attached. I'm less sure about the patch, but it seems to
> work and is unlikely to break anything other than WARN_CREATE_GLOBAL.
> if (varspc) {
> - addvars(state, varspc, ADDVAR_EXPORT|ADDVAR_RESTRICT);
> + int addflags = ADDVAR_EXPORT|ADDVAR_RESTRICT;
> + if (forked)
> + addflags |= ADDVAR_RESTORE;
> + addvars(state, varspc, addflags);
> if (errflag)
> _exit(1);
> }
It looks plausible. "forked" is a local variable in execcmd() saying we
forked to execute whatever it is, so it indicates the variable can't
leak from the current command context. ADVAR_RESTORE is only a signal
to quieten the warning (it could be better named; the name comes from
the other time it's set rather than it's real purpose). So it certainly
looks better than before.
Thanks
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author