Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Optimization of getarrvalue()



On Mon, 14 Nov 2016 21:32:19 +0900
Jun T. <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
> The problem comes from the last line of _sequence:
> 
> "${(@)argv[1,minus-1]}" .... "${(@)argv[minus+1,-1]}"
> 
> In the case of 'ps -p <TAB>', argv=( _pids ) and minus=2.
> We expect that, since it has a (@) flag, "${(@)argv[3,-1]}" is
> entirely removed from the command line. This is indeed the case
> before the commit:
> 
> zsh% a=( foo )
> zsh% nargs () { print $#@ }
> zsh% nargs "${a[3,-1]}"
> 1
> zsh% nargs "${(@)a[3,-1]}"
> 0

Here's a test for this.

pws

diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 97c8ba3..4cbd2fa 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2041,3 +2041,11 @@
   () { print -r -- "${(q)1}" "${(b)1}" "${(qq)1}" } '=foo'
 0:(q) and (b) quoting deal with the EQUALS option
 >\=foo =foo '=foo'
+
+  args() { print $#; }
+  a=(foo)
+  args "${a[3,-1]}"
+  args "${(@)a[3,-1]}"
+0:Out-of-range multiple array subscripts with quoting, with and without (@)
+>1
+>0



Messages sorted by: Reverse Date, Date, Thread, Author