zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] Fix a WARN_CREATE_GLOBAL false positive.
Date: Fri, 6 Dec 2013 09:47:28 +0200	[thread overview]
Message-ID: <20131206074728.GA2313@tarsus.local2> (raw)

---
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.

Daniel

 Src/exec.c           |    5 ++++-
 Test/E01options.ztst |    1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git Src/exec.c Src/exec.c
index df915e1..dccdc2b 100644
--- Src/exec.c
+++ Src/exec.c
@@ -3309,7 +3309,10 @@ execcmd(Estate state, int input, int output, int how, int last1)
 	    }
 	    if (type == WC_SIMPLE) {
 		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);
 		}
diff --git Test/E01options.ztst Test/E01options.ztst
index e00eb0e..48f3ffc 100644
--- Test/E01options.ztst
+++ Test/E01options.ztst
@@ -1067,6 +1067,7 @@
     fn2() {
       foo3=bar6
     }
+    foo4=bar7 =true
   }
   fn
 0:WARN_CREATE_GLOBAL option
-- 
1.7.10.4


             reply	other threads:[~2013-12-06  7:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06  7:47 Daniel Shahaf [this message]
2013-12-06  9:23 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131206074728.GA2313@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).