help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Is there a way to set a var above it's current scope?
Date: Sat, 18 Feb 2023 17:17:21 +0100	[thread overview]
Message-ID: <CAKc7PVCDxuJ6wx6CQrZ2j15bdyHO-9uqga2x1N5XiRRhV_ZRbg@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMrcTjfEJ_Tbubg_h70L4mGgh5Y4anap8ff-LSHXDhqKSA@mail.gmail.com>

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

Yes I know, also one can use local at global scope to have the same effect
as typeset -g there, this is a direct effect of how scopes are implemented.

sob., 18 lut 2023, 16:30 użytkownik Roman Perepelitsa <
roman.perepelitsa@gmail.com> napisał:

> On Sat, Feb 18, 2023 at 3:57 PM Sebastian Gniazdowski
> <sgniazdowski@gmail.com> wrote:
> >
> > Somewhere in the man I saw something like: if you use export you'll
> > always set in global scope, regardless of any local variable
> > collision.
> You might be confusing it with the fact that `typeset -x q` is
> equivalent to `typeset -gx q` and `export q` when used within a
> function, even though normally `typeset` within a function is
> equivalent to `local`.
> > Is there any way of achieving this?
> If there is a variable in function scope, there is no way to do
> anything with the identically-named variable in global scope.
>     q=42
>     () {
>       local q;
>       # Nothing you can do here will have any
>       # effect on the global `q`.
>     }
> Roman.

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

      reply	other threads:[~2023-02-18 16:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-18 14:55 Sebastian Gniazdowski
2023-02-18 15:29 ` Roman Perepelitsa
2023-02-18 16:17   ` Sebastian Gniazdowski [this message]

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKc7PVCDxuJ6wx6CQrZ2j15bdyHO-9uqga2x1N5XiRRhV_ZRbg@mail.gmail.com \
    --to=sgniazdowski@gmail.com \
    --cc=roman.perepelitsa@gmail.com \
    --cc=zsh-workers@zsh.org \


* 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


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).