zsh-users
 help / color / mirror / code / Atom feed
From: Eric Nielsen <ericbn@hey.com>
To: "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Assign to outer parameter from function called by zargs
Date: Tue, 28 Mar 2023 11:24:31 -0500	[thread overview]
Message-ID: <db828e7542e0c1a9738d1a6acc90eae6c5175075@hey.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 762 bytes --]

Hi. I'm trying to assign to a parameter set by an outer function from a
function called by zargs.

Accessing instead of assigning works:

access_outer() {
  print ${outer}${1}
}
() {
  autoload -Uz zargs
  local outer=a
  zargs -n 1 -P 0 -- b c -- access_outer
}

results in:
ab
ac
as expected.

But assigning does not work as I was expecting:

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
(or acb, I don't care about the order since I'm using -P 0 and I expect
paralellism could interfere with the order)

What am I missing?

--
Sent with HEY <https://hey.com/sent>

[-- Attachment #2: Type: text/html, Size: 3367 bytes --]

             reply	other threads:[~2023-03-28 16:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 16:24 Eric Nielsen [this message]
2023-03-28 17:50 ` Roman Perepelitsa
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=db828e7542e0c1a9738d1a6acc90eae6c5175075@hey.com \
    --to=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).