zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: readonly, export, and local
Date: Tue, 1 Mar 2011 19:02:33 -0800	[thread overview]
Message-ID: <AANLkTi=W0H22eeh=rwM5SAcMctGTgXay0vZuAU0f4imH@mail.gmail.com> (raw)

Chet Ramey on the austin-group list:
> ksh93 does dynamic scoping if the local
> variable shadows a global variable with the export attribute set.  This
> means that it will pass the local variable value to both child functions
> and external commands, and not permit a local variable with the same name
> as a global variable with both the export and readonly attributes (in
> fact, that is a fatal error).

This has me wondering whether zsh should do something similar.  If I
have declared an exported variable as readonly, does that not imply
that I expect that value to be the one placed in the environment of
any external command that may be executed?

Yet zsh allows "local -x" to cause the local copy of a variable to go
into the environment instead, even when the variable of the same name
in the surrounding scope is marked readonly.

Certainly either semantics could be argued.  Zsh's current behavior
provides a slightly better illusion of lexical scope.


                 reply	other threads:[~2011-03-02  3:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='AANLkTi=W0H22eeh=rwM5SAcMctGTgXay0vZuAU0f4imH@mail.gmail.com' \
    --to=schaefer@brasslantern.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).