Re: Variable expansion inside of functions

Bart Schaefer <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.