Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Global array actually not available
- X-seq: zsh-users 21715
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Global array actually not available
- Date: Thu, 30 Jun 2016 10:04:53 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=95RwYl3rqqVcTvULnrHvoQvNoIifM0tSWajnQg3Vzks=; b=DT+x2muMDyBIu97esu5WkMYcQoOF774CfIoksABQuFY4GDg04gYP2Lu04ySCVr+ZC1 g6S4TlWfX3dEXQKBLsZWwxI2Nx+D6Zz+iruRqfanJ0VNI8LAX5D8YKJ6ovRZ0s0QlaBc xIFWXTQ+ze3cqcYkNcppR2lbAdHpop8wjct/jxjo4kZtz1mJWr9ah5A+4/ffy/JPxAEq 0Kl3HsRmQLRqXy4CdeDsLA4v0NRrI/IOvsUzsyNZE0yIpcYIz3dDY4ISoHQyqEGhVd5u YO+lSqXRBuLkwI2Zcl+8XMQfgWO8gZVssd0pi3gIJMXRDvXUGOPFc859HGqgmhl0mN61 /YIA==
- In-reply-to: <CAKc7PVCTQDEvtirfeZF-0885pXEZwvXbR+DvO9k-QoQWKYpVPg@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVCTQDEvtirfeZF-0885pXEZwvXbR+DvO9k-QoQWKYpVPg@mail.gmail.com>
On Jun 30, 4:34pm, Sebastian Gniazdowski wrote:
}
} In code, I declare reply2 and reply3 as arrays via typeset -ga. I do
} this from inside of a function. When the code returns to outer scope,
} (t)reply2 and (t)reply3 show empty strings.
I see your follow-up in which it appears this may be attributable to
separate shell processes, but in addition please note that typeset -g
does not actually declare a "global" variable (despite the mnemonic).
It merely declares a "non-local" variable. The actual dynamic scope
of the variable will be the nearest surrounding scope in which that
parameter's name is already defined (even if both defined AND unset;
in the unset case it may become set again, but it's scope remains).
Thus "typeset -g name" declares a true global $name only when there
is not another $name already declared (or $name is already global,
of course).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author