Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[bug?] word based string subscripting past the end
- X-seq: zsh-workers 54772
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [bug?] word based string subscripting past the end
- Date: Sun, 14 Jun 2026 13:15:58 +0100
- Archived-at: <https://zsh.org/workers/54772>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
$ a='foo bar baz' zsh -c 'print -r - $a[(w)3,(w)3]'
baz
$ a='foo bar baz' zsh -c 'print -r - $a[(w)3,(w)4]'
baz
OK but:
$ a='foo bar baz' zsh -c 'print -r - $a[(w)4,(w)4]'
baz
$ a='foo bar baz' zsh -c 'print -r - $a[(w)4,(w)-1]'
baz
I'd have expected an empty output like for character
subscripting or array subscripting:
$ a='abc' zsh -c 'print -r - $a[4,4]'
$ a='abc' zsh -c 'print -r - $a[4,-1]'
$ zsh -c 'a=(a b c); print -r - $a[4,4]'
$ zsh -c 'a=(a b c); print -r - $a[4,-1]'
$
(with 5.9 and latest devel).
Cheers,
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author