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

Re: Defining variables in the caller's environment (was: ERR_RETURN ignored in 'if' in a source'd file [FIXED])



On Tue, May 20, 2025 at 3:52 AM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> In Zsh 5.10 and above, $( ... ) can be replaced with ${ ... } to avoid forking.
>
>     function define-vars() {
>       local -A var1=("$1" "$2")
>       local -i var2=42
>       typeset -p -- var1 var2
>     }

Also
  eval ${ define-vars 'x' 'y $ z' }

Which is an idiom in use for many years, e.g.
  eval $(ssh-agent)




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