diff options
author | Barton E. Schaefer <schaefer@zsh.org> | 2016-11-29 12:31:33 -0800 |
---|---|---|
committer | Barton E. Schaefer <schaefer@zsh.org> | 2016-11-29 12:31:33 -0800 |
commit | a9fe87e18cbe37d938fb1a02f71f8f905141e0f4 (patch) | |
tree | 5dc639bb9f74fa915362366c4c08ed50f332e083 /Src | |
parent | 596ba302e6f23089e58ff05d75fedfca8e79a7d2 (diff) | |
download | zsh-a9fe87e18cbe37d938fb1a02f71f8f905141e0f4.tar.gz zsh-a9fe87e18cbe37d938fb1a02f71f8f905141e0f4.tar.xz zsh-a9fe87e18cbe37d938fb1a02f71f8f905141e0f4.zip |
40032: consistency in handling of subscript slices outside the bounds of an array parameter
unposted: README: example describing 40032
Diffstat (limited to 'Src')
-rw-r--r-- | Src/params.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Src/params.c b/Src/params.c index 45f398a27..aa8b196bd 100644 --- a/Src/params.c +++ b/Src/params.c @@ -2299,9 +2299,16 @@ getarrvalue(Value v) if (v->end <= v->start) { s = arrdup_max(nular, 0); } - else if (arrlen_lt(s, v->start) || v->start < 0) { + else if (v->start < 0) { s = arrdup_max(nular, 1); - } else { + } + else if (arrlen_le(s, v->start)) { + /* Handle $ary[i,i] consistently for any $i > $#ary + * and $ary[i,j] consistently for any $j > $i > $#ary + */ + s = arrdup_max(nular, v->end - (v->start + 1)); + } + else { /* Copy to a point before the end of the source array: * arrdup_max will copy at most v->end - v->start elements, * starting from v->start element. Original code said: |