Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Interpret Parameter Value at Time of Function Definition



Vin Shelton wrote on Tue, 05 Sep 2017 09:47 -0400:
> $ aaa=bbb
> $ function t {
>     print aaa = \"$aaa\"
>   }
> 
> I would like to interpret $aaa at read time, so that:
> 
>     aaa=ccc t
> 
> would print:
> 
>     aaa = "bbb"

Declare aaa local inside the function:

t() {
  local aaa=bbb
  typeset -p aaa
}
aaa=ccc t

... but then, if t() changes $aaa the changes won't be visible outside t().



Messages sorted by: Reverse Date, Date, Thread, Author