zsh-workers
 help / color / mirror / code / Atom feed
* readonly, export, and local
@ 2011-03-02  3:02 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2011-03-02  3:02 UTC (permalink / raw)
  To: Zsh hackers list

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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-03-02  3:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-02  3:02 readonly, export, and local Bart Schaefer

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