From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Eric Nielsen <ericbn@hey.com>
Cc: "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: Assign to outer parameter from function called by zargs
Date: Tue, 28 Mar 2023 19:50:12 +0200 [thread overview]
Message-ID: <CAN=4vMp0b0wOK2mSSYKFnZGiY3jFW_oGAmsT_O-d2EdpCD-9nQ@mail.gmail.com> (raw)
In-Reply-To: <db828e7542e0c1a9738d1a6acc90eae6c5175075@hey.com>
On Tue, Mar 28, 2023 at 6:25 PM Eric Nielsen <ericbn@hey.com> wrote:
>
> assign_outer() {
> outer=${outer}${1}
> }
> () {
> autoload -Uz zargs
> local outer=a
> zargs -n 1 -P 0 -- b c -- assign_outer
> print ${outer}
> }
>
> results in:
> a
> and I was expecting to get:
> abc
assign_outer runs in a subshell, so it cannot modify the parameters of
the parent shell. It's similar to this:
outer=a
( outer+=b ) &
( outer+=c ) &
wait
print $outer # still "a"
Roman.
next prev parent reply other threads:[~2023-03-28 17:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 16:24 Eric Nielsen
2023-03-28 17:50 ` Roman Perepelitsa [this message]
2023-03-28 19:53 ` Bart Schaefer
2023-03-28 20:34 ` Eric Nielsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAN=4vMp0b0wOK2mSSYKFnZGiY3jFW_oGAmsT_O-d2EdpCD-9nQ@mail.gmail.com' \
--to=roman.perepelitsa@gmail.com \
--cc=ericbn@hey.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).