Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Variable expansion inside of functions
- X-seq: zsh-users 30600
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Variable expansion inside of functions
- Date: Sat, 18 Apr 2026 12:51:47 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=G2nZDMbNrk2ZIuhGaAlPyhVQPMZBgsu93WipFt17UkM=; fh=yk3c4scJWo86Za4IR1HBNZw2a+GkUkfVQ7Fs3jnanfg=; b=SzS/zvaZkQ5ItJMLTmll0B6stY4r/vONrRJb+9+b6h+U2j0HjN5jAGbEPDqenYFCvp c5LYT/54tNkcdiUwrrcyfq50vTLGBs6E2l56P5QUyPp4gwwThLAee8aTVqh3vSfAoBV/ 8YrXUV5+8F3bAUGIDGiXXlk+/tsKCwiL7Cx3+MC2lXoznS3CTxzwDGe68reRRAE7gcAL LbCY8yFpaPx3y3BTO58cF0xU0EbdDuYo0uT0buU4IaHeo+qitlGJe6vIcY66hHSwKSec m928jif0SxPMCj17tvNxegIJDYxQNh8QrXAFp4O5nJYdJf+7wukvN2fUrnvzRJ8mSiGM g2/A==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1776541918; cv=none; d=google.com; s=arc-20240605; b=liL4tDHXLLnh2/Y66vuuoq8UvrJjbNeuQPeP+6YPa+rpGdXiNESIjkRdQGQrPThXCF nGYCaWeuhEDKdv/Edb3Zz56EhdjgWgygXFVu7cStA2svR6ppdI6POsQ9fkpz8PKVfIC0 rpOXdIX9mZ13+2NYveKi7FZ+sPvKVL7LNgF7imGgHXc4r/ce3c+v/hVsyBmV9xpGZto1 /ub9cEFkFdUUcXNdKZTev4J28eKoVW2MWsWLjC6QIVGedeLwriDaMwGWkORNT8Pj2zoN 2uMKgBVjrwtIFU2n77W3APAnnqzGfO5bOoXcE0zEU53uKiO8EE64fsbKxd5cKFVV/6Mr XlHQ==
- Archived-at: <https://zsh.org/users/30600>
- In-reply-to: <20260418T135301Z.GLumbW4C--Uw@fnord.qqx.org>
- List-id: <zsh-users.zsh.org>
- References: <aeN6GjRBGVWDG6SP@chil> <20260418T135301Z.GLumbW4C--Uw@fnord.qqx.org>
On Sat, Apr 18, 2026 at 6:53 AM Aaron Schrab <aaron@xxxxxxxxxx> 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
> }
> }
Messages sorted by:
Reverse Date,
Date,
Thread,
Author