Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Fix command executions w/ shadowing array parameter with ksharrays set
Signed-off-by: Takeshi Banse <takebi@xxxxxxxxx>
---
* Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> [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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author