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])
- X-seq: zsh-users 30265
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh-Users List <zsh-users@xxxxxxx>
- Subject: Re: Defining variables in the caller's environment (was: ERR_RETURN ignored in 'if' in a source'd file [FIXED])
- Date: Tue, 20 May 2025 09:12:46 -0700
- Archived-at: <https://zsh.org/users/30265>
- In-reply-to: <CAN=4vMrc9u4NBEuCBhfPQFt8qLSWxOENTwfVn3j10dAB_JpsEQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAGdYchvkvCTV0HQ1RqTCP8pTX8pDbc6+P=5mrPq3UGiUfeODzw@mail.gmail.com> <CAN=4vMrc9u4NBEuCBhfPQFt8qLSWxOENTwfVn3j10dAB_JpsEQ@mail.gmail.com>
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