From: Takeshi Banse <takebi@laafc.net>
To: zsh-workers@zsh.org
Cc: Takeshi Banse <takebi@laafc.net>
Subject: [PATCH] Fix command executions w/ Fix command executions w/ shadowing array parameter with ksharrays set
Date: Sun, 28 Dec 2014 08:56:30 +0900 [thread overview]
Message-ID: <1419724590-8184-1-git-send-email-takebi@laafc.net> (raw)
In-Reply-To: <141227120009.ZM5338@torch.brasslantern.com>
Signed-off-by: Takeshi Banse <takebi@laafc.net>
---
* Bart Schaefer <schaefer@brasslantern.com> [2014-12-28 05:00]:
> On Dec 27, 1:45pm, Takeshi Banse wrote:
> }
> } +++ b/Src/exec.c
> } @@ -2294,6 +2294,8 @@ addvars(Estate state, Wordcode pc, int addflags)
> } }
> } allexp = opts[ALLEXPORT];
> } opts[ALLEXPORT] = 1;
> } + if (unset(KSHARRAYS))
> } + unsetparam(name);
> } pm = assignsparam(name, val, myflags);
> } opts[ALLEXPORT] = allexp;
> } } else
>
> That needs to be isset(KSHARRAYS) rather than unset(), I think?
Ugh...Sorry for the inconvenience. I've updated the patch.
Thank you for your help, Bart. Here is updated patch:
- isset(KSHARRAYS)
- printenv => /bin/sh -c 'echo $A'
- fix typo; use ksharrays rather than ksharray
Src/exec.c | 2 ++
Test/A06assign.ztst | 18 ++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/Src/exec.c b/Src/exec.c
index 6a7dbb1..3462929 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2294,6 +2294,8 @@ addvars(Estate state, Wordcode pc, int addflags)
}
allexp = opts[ALLEXPORT];
opts[ALLEXPORT] = 1;
+ if (isset(KSHARRAYS))
+ unsetparam(name);
pm = assignsparam(name, val, myflags);
opts[ALLEXPORT] = allexp;
} else
diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst
index 3c9ea08..0ad9a0a 100644
--- a/Test/A06assign.ztst
+++ b/Test/A06assign.ztst
@@ -433,3 +433,21 @@
>n=(tmpfile1 tmpfile2)
>typeset x=tmpfile2
>typeset -E f=4.000000000e+00
+
+ A=(first second)
+ A="${A[*]}" /bin/sh -c 'echo $A'
+ print -l "${A[@]}"
+0:command execution with assignments shadowing array parameter
+>first second
+>first
+>second
+
+ setopt ksharrays
+ A=(first second)
+ A="${A[*]}" /bin/sh -c 'echo $A'
+ print -l "${A[@]}"
+ unsetopt ksharrays
+0:command execution with assignments shadowing array parameter with ksharrays
+>first second
+>first
+>second
--
2.1.4
next prev parent reply other threads:[~2014-12-27 23:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-27 4:45 [PATCH] Fix command executions w/ shadowing array parameter with ksharray set Takeshi Banse
2014-12-27 20:00 ` Bart Schaefer
2014-12-27 23:56 ` Takeshi Banse [this message]
2014-12-28 0:02 ` Fix command executions w/ Fix command executions w/ shadowing array parameter with ksharrays set Takeshi Banse
2014-12-28 0:10 ` [PATCH] " Takeshi Banse
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=1419724590-8184-1-git-send-email-takebi@laafc.net \
--to=takebi@laafc.net \
--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).