Re: Defining variables in the caller's environment (was: ERR_RETURN ignored in 'if' in a source'd file [FIXED])
Bart Schaefer <[email protected]>
| Newsgroups | gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAH+w=7YBvTnka1vXqYiPOLopSCQxtC+9N_Rjej9UhkJcpfZSQQ@mail.gmail.com> |
On Tue, May 20, 2025 at 3:52 AM Roman Perepelitsa <[email protected]> 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)