* [PATCH] Fix command executions w/ shadowing array parameter with ksharray set
@ 2014-12-27 4:45 Takeshi Banse
2014-12-27 20:00 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Takeshi Banse @ 2014-12-27 4:45 UTC (permalink / raw)
To: zsh-workers; +Cc: Takeshi Banse
Signed-off-by: Takeshi Banse <takebi@laafc.net>
---
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix command executions w/ shadowing array parameter with ksharray set
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 ` [PATCH] Fix command executions w/ Fix command executions w/ shadowing array parameter with ksharrays set Takeshi Banse
2014-12-28 0:10 ` [PATCH] " Takeshi Banse
0 siblings, 2 replies; 5+ messages in thread
From: Bart Schaefer @ 2014-12-27 20:00 UTC (permalink / raw)
To: Takeshi Banse, zsh-workers
Thanks, I can confirm the bug.
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?
} diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst
} + A="${A[*]}" printenv A
I'm not sure we can rely on "printenv" being available as a command at
test time. Can anyone suggest a good alternative? /bin/sh -c 'echo $A'
perhaps?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Fix command executions w/ Fix command executions w/ shadowing array parameter with ksharrays set
2014-12-27 20:00 ` Bart Schaefer
@ 2014-12-27 23:56 ` Takeshi Banse
2014-12-28 0:02 ` Takeshi Banse
2014-12-28 0:10 ` [PATCH] " Takeshi Banse
1 sibling, 1 reply; 5+ messages in thread
From: Takeshi Banse @ 2014-12-27 23:56 UTC (permalink / raw)
To: zsh-workers; +Cc: Takeshi Banse
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fix command executions w/ Fix command executions w/ shadowing array parameter with ksharrays set
2014-12-27 23:56 ` [PATCH] Fix command executions w/ Fix command executions w/ shadowing array parameter with ksharrays set Takeshi Banse
@ 2014-12-28 0:02 ` Takeshi Banse
0 siblings, 0 replies; 5+ messages in thread
From: Takeshi Banse @ 2014-12-28 0:02 UTC (permalink / raw)
To: zsh-workers
I'm very sorry. The subject is borked. I'll resend it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Fix command executions w/ shadowing array parameter with ksharrays set
2014-12-27 20:00 ` Bart Schaefer
2014-12-27 23:56 ` [PATCH] Fix command executions w/ Fix command executions w/ shadowing array parameter with ksharrays set Takeshi Banse
@ 2014-12-28 0:10 ` Takeshi Banse
1 sibling, 0 replies; 5+ messages in thread
From: Takeshi Banse @ 2014-12-28 0:10 UTC (permalink / raw)
To: zsh-workers; +Cc: Takeshi Banse
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-12-28 0:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH] Fix command executions w/ Fix command executions w/ shadowing array parameter with ksharrays set Takeshi Banse
2014-12-28 0:02 ` Takeshi Banse
2014-12-28 0:10 ` [PATCH] " Takeshi Banse
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).