Re: Variable expansion inside of functions
"Mark J. Reed" <[email protected]> Sat, 18 Apr 2026 17:07:26 -0400
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAA=-s3w7Cafq7qDtnToa402gUatQrizRTzzFTmqS+QHu9atg7g@mail.gmail.com> |
On Sat, Apr 18, 2026 at 3:58 PM Bart Schaefer <[email protected]> wrote: > 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. > But the quoted snippet doesn't use bare $+name; it uses $+name[index], which does return the appropriate result for that specific element of the array. Worth mentioning that $+name is 1 even for an empty array, where $+name[1] in that case will be 0. -- Mark J. Reed <[email protected]>