Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Fix command executions w/ shadowing array parameter with ksharray set
- X-seq: zsh-workers 34060
- From: Takeshi Banse <takebi@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Fix command executions w/ shadowing array parameter with ksharray set
- Date: Sat, 27 Dec 2014 13:45:41 +0900
- Cc: Takeshi Banse <takebi@xxxxxxxxx>
- 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
Signed-off-by: Takeshi Banse <takebi@xxxxxxxxx>
---
I am not quite sure that this patch is in a good shape or not, but it fixes
this particular problem here.
It prints "A" without 'ksharrays', but does not print if 'ksharays' is set.
For example:
% zsh -f -c 'A=(a b c); A=A printenv A'
=> A
% zsh -f -c 'setopt ksharrays; A=(a b c); A=A printenv A'
=> ;# does not print 'A' in this case.
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..61bf7a4 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 (unset(KSHARRAYS))
+ unsetparam(name);
pm = assignsparam(name, val, myflags);
opts[ALLEXPORT] = allexp;
} else
diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst
index 3c9ea08..057ab43 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[*]}" printenv A
+ print -l "${A[@]}"
+0:command execution with assignments shadowing array parameter
+>first second
+>first
+>second
+
+ setopt ksharrays
+ A=(first second)
+ A="${A[*]}" printenv A
+ print -l "${A[@]}"
+ unsetopt ksharrays
+0:command execution with assignments shadowing array parameter with ksharray
+>first second
+>first
+>second
--
2.1.4
Messages sorted by:
Reverse Date,
Date,
Thread,
Author