Re: Variable expansion inside of functions
Bart Schaefer <[email protected]> Sat, 18 Apr 2026 12:51:47 -0700
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAH+w=7YnhRNMgfTthAL=Tdd7VPGFETJMMe2D6SA1z46fxs4Bzw@mail.gmail.com> |
On Sat, Apr 18, 2026 at 6:53 AM Aaron Schrab <[email protected]> wrote: > > might be clearer to have the loop just build up a $cmds array (I'd call > it $commands, but zsh already defines that) You can bypass that if you use local -aH commands but clearly you don't want to do that here because you're using $commands to check existence. > () { > local -a cmds > for i in pdfgrep rg > do > (( $+commands[$i] )) && cmds+=$i > done > > $commands() { Pointing out this is a typo, it'll create a wrapper for all/every known commands. Should be $cmds > # build $arg > command $0 $arg > } > }