help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Sebastian Gniazdowski <sgniazdowski@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 16:29:54 +0100	[thread overview]
Message-ID: <CAN=4vMrcTjfEJ_Tbubg_h70L4mGgh5Y4anap8ff-LSHXDhqKSA@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVCGCCxS6bhRuFa=KN=hj0-tNfzA6pFMUoQbEG=yZuoDOA@mail.gmail.com>

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.


    () {
      local q;
      # Nothing you can do here will have any
      # effect on the global `q`.


  reply	other threads:[~2023-02-18 15:30 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 [this message]
2023-02-18 16:17   ` Sebastian Gniazdowski

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='CAN=4vMrcTjfEJ_Tbubg_h70L4mGgh5Y4anap8ff-LSHXDhqKSA@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=sgniazdowski@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).