Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Fix a WARN_CREATE_GLOBAL false positive.
- X-seq: zsh-workers 32091
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Fix a WARN_CREATE_GLOBAL false positive.
- Date: Fri, 6 Dec 2013 09:47:28 +0200
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:subject:message-id :mime-version:content-type; s=mesmtp; bh=tygnLgcTl2Vy6ljfM6jFh72 oZQo=; b=vaN9h9fG2P4W9WBATLrVgOcSP/51BC3ZGr8ToIG56bbMoSng4MvnCir Jk/CAW/ge2OePszqlUV2dT3u4dykavBoZnOrxnwZC2o+X8CprS0bu41JM3A7AGsV ZZcD4OzyfS6XL0ZOSR6JZjXX17BUYj++oCA/qlar0ijtlHllYxmI=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:subject:message-id :mime-version:content-type; s=smtpout; bh=tygnLgcTl2Vy6ljfM6jFh7 2oZQo=; b=Ni3daNCCZ+SBJjk8ZGgOixnyJ650Xbi7oqWdCeIsNzLB0Zn19CKAk/ Hy/WQNT9Hk6g0IqwpYQaVNz9cJgay3sLCzMMYujCWH3nuoyYKyn7FIUs4nBUPSrg LOU5l2VKNqkmhbUizb+ZvbkOENn+TnwLqHrFfmUwIjAhbCDt4kmCM=
- 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
---
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author