Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH 1/3]: Add named references
- X-seq: zsh-workers 51420
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH 1/3]: Add named references
- Date: Sun, 12 Feb 2023 23:54:00 +0100
- Archived-at: <https://zsh.org/workers/51420>
- In-reply-to: <CAH+w=7ZWQ_KgSmLDeC6hDq+dsZVeK-29NriD0h0BdL60TOfTYQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7bd5tHQ8_ZFuyheUrTStm8pR826jH1LB-vMdEnv14nH0w@mail.gmail.com> <67689-1675827940.088548@BxvG.D9_b.7RzI> <CAH+w=7ZFq_MyNtPVetDt84Zp8dnCQXis3p=2sKP018GZ-VTd0g@mail.gmail.com> <12608-1675903622.800470@Xj82.e3y1.svhG> <CAH+w=7ZZUCqYe6w1ZqZZKR6iLsZH0SDDXyzwgTU93nxx6bmxjQ@mail.gmail.com> <66045-1675975796.128039@FBF_.0yMO.Y8fk> <CAH+w=7bcqc8SsRxsht0QFyXy=DYzj6nVaBFhdzQ5MrBB+yBz+A@mail.gmail.com> <94092-1676192523.865597@yGHQ.rexg.4E4Z> <CAH+w=7ZWQ_KgSmLDeC6hDq+dsZVeK-29NriD0h0BdL60TOfTYQ@mail.gmail.com>
Bart Schaefer wrote:
> On Sun, Feb 12, 2023 at 1:02 AM Oliver Kiddle <opk@xxxxxxx> wrote:
> >
> > % typeset -n ref=arr[1]whatever
> > % echo $ref
> > onewhatever
>
> Aha. OK, that's pretty easy to fix.
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.
> What about adding ${(K)array) to return array[1] array[2] ... ?
>
> for ref in ${(K)hash}; do ...
That'd work. There's been a few times when I've wished (k) and (kv)
would work for normal arrays. the former is just {1..$#arr} but would
work in nested expansions.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author