zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Marlon Richert <marlon.richert@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] zsh/param/private scoping error
Date: Wed, 1 Sep 2021 07:39:34 -0700	[thread overview]
Message-ID: <CAH+w=7agEjSXRYBuKyVsCM+HUqCX4-y975wfKe7bDgH+OLs3vA@mail.gmail.com> (raw)
In-Reply-To: <CAHLkEDtxe8wtOZ8dWC2tUdhQBpSZtKjGc7MrzJYBJ9oPdjP9Pw@mail.gmail.com>

On Wed, Sep 1, 2021 at 4:51 AM Marlon Richert <marlon.richert@gmail.com> wrote:
>
> % () { private tst; () { tst= } }
> (anon):1: tst: attempt to assign private in nested scope
> %
>
> This is not how one would expect private variables to behave.

But it's how variable scoping behaves in the shell language.  If I do

% () { local tst; () { tst=foo } }

Then it is the tst in the surrounding scope that gets altered, not the
global one.  If the inner function is INTENDED to create a global, it
should be using "typeset -g" explicitly.


  parent reply	other threads:[~2021-09-01 14:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 11:49 Marlon Richert
2021-09-01 14:09 ` Daniel Shahaf
2021-09-01 16:21   ` Marlon Richert
2021-09-01 14:39 ` Bart Schaefer [this message]
2021-09-01 16:03   ` Mikael Magnusson
2021-09-01 16:11     ` Marlon Richert
2021-09-01 17:00       ` Mikael Magnusson
2021-09-01 17:35         ` Bart Schaefer
2021-10-03 21:55           ` Bart Schaefer
2021-10-04  4:54             ` Mikael Magnusson
2021-10-04 15:12               ` Bart Schaefer

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='CAH+w=7agEjSXRYBuKyVsCM+HUqCX4-y975wfKe7bDgH+OLs3vA@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=marlon.richert@gmail.com \
    --cc=zsh-workers@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).