From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12477 invoked by alias); 6 Dec 2013 09:33:22 -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: 32092 Received: (qmail 5936 invoked from network); 6 Dec 2013 09:33:16 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f4-b7f966d0000003d9-b6-52a1977d0e1d Date: Fri, 06 Dec 2013 09:23:09 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: [PATCH] Fix a WARN_CREATE_GLOBAL false positive. Message-id: <20131206092309.1831da0c@pwslap01u.europe.root.pri> In-reply-to: <20131206074728.GA2313@tarsus.local2> References: <20131206074728.GA2313@tarsus.local2> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphluLIzCtJLcpLzFFi42I5/e/4Zd3a6QuDDJ4eZbc42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGffuvWEtOM1RcXZ6fAPjBbYuRk4OCQETic27PrJA2GISF+6t B4pzcQgJLGWU+P3wGTuEs5xJYtHh42BVLAKqEqcnN4HZbAKGElM3zWYEsUUExCXOrj0PFhcW sJW4e+4lO4jNK2Av0dmzDSzOKWAksennXyYQWwio99/fWawgNr+AvsTVv5+YIK6wl5h55Qwj RK+gxI/J98B6mQW0JDZva2KFsOUlNq95yzyBUWAWkrJZSMpmISlbwMi8ilE0tTS5oDgpPddQ rzgxt7g0L10vOT93EyMkBL/sYFx8zOoQowAHoxIPb8KaBUFCrIllxZW5hxglOJiVRHh7xBcG CfGmJFZWpRblxxeV5qQWH2Jk4uCUamA0fzvp65bYp6zbteefmvpPOpzplFz9i7/flGND26um XVA6IOh1yXzPK68JvMyi/fPuckvG3T8pFP044teh7Nbp5/IUdEX8co4Yav+fati26oubIU9Y 1EzRx/wVlSryaVz80j/O5AWG3ZguyhYx/1BHCdesuQbxdyJ/Wyz3mrEw98DEqcHcO94osRRn JBpqMRcVJwIALLseRh8CAAA= On Fri, 06 Dec 2013 09:47:28 +0200 Daniel Shahaf 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