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

Re: [PATCH] More rigorous subscript checking in named references



On Sun, Feb 12, 2023 at 12:16 PM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> This covers the case Oliver called out, of extra stuff following a
> valid subscript.

On Sun, Feb 12, 2023 at 2:54 PM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> That still leaves the oddities with a second subscript:
>
>   typeset -n ref='arr[2][1]'
>   arr=( one two three )
>   echo $ref
>   echo ${ref}
>   ref=Z
>   typeset -p arr
>
> Only case where the second subscript works is when ref is in braces.

Hmm ... I think that has something to do with this:

% arr[2]=two
% arr[2][1]=Z
zsh: no matches found: arr[2][1]=Z

That is, there's a level deeper than where namerefs operate that
doesn't parse past the first subscript.  I'm not sure how hard to work
on that (or if we even want the latter case to work).

I'll keep a note of it, though.




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