From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17618 invoked by alias); 28 Dec 2014 00:10:29 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34064 Received: (qmail 26875 invoked from network); 28 Dec 2014 00:10:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 From: Takeshi Banse To: zsh-workers@zsh.org Cc: Takeshi Banse Subject: [PATCH] Fix command executions w/ shadowing array parameter with ksharrays set Date: Sun, 28 Dec 2014 09:10:24 +0900 Message-Id: <1419725424-22937-1-git-send-email-takebi@laafc.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <141227120009.ZM5338@torch.brasslantern.com> References: <141227120009.ZM5338@torch.brasslantern.com> Signed-off-by: Takeshi Banse --- * Bart Schaefer [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