Re: Variable expansion inside of functions

Bart Schaefer <[email protected]> Sat, 18 Apr 2026 12:55:13 -0700
Newsgroups gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user
Message-ID <CAH+w=7aHUsxvupAs0PBOsq7qWZOQURxmGVRNzXZujpH357PhCQ@mail.gmail.com>
On Sat, Apr 18, 2026 at 7:26 AM Klaus Ethgen <[email protected]> wrote:
>
> >      (( $+commands[$i] )) && cmds+=$i
>
> Sane solution for whence -p. I did not know $+... And I do not find it
> in the documentation. Only ${{+...}} but that is about parameters and
> not about arrays.

Arrays are parameters.  Everything described in the section on
parameters applies to arrays (and associative arrays / hashes) as
well.  The semantics may differ slightly -- sometimes every array
element is affected individually, sometimes the whole array is
examined.  For $+name (which is shorthand for ${+name}), it's the
whole array.