Zsh Mailing List Archive
Messages sorted by:
What is the environment? (Re: code completition / cannot delete characters)
- X-seq: zsh-users 11296
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: What is the environment? (Re: code completition / cannot delete characters)
- Date: Sun, 11 Mar 2007 21:41:11 -0700
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
This might be of general interest. (Anupam has let me know that he did
not intend to exclude the list from the conversation.)
--- Forwarded mail from "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
Date: Sun, 11 Mar 2007 11:32:50 -0700
To: "Anupam Srivastava" <anupam.srivastava@xxxxxxxxx>
Subject: Re: code completition / cannot delete characters
On Mar 11, 6:59pm, Anupam Srivastava wrote:
} So not-using-export is not specific to PROMPT/RPROMPT but to all
No, that would be too broad a statement.
} I was under the impression that export makes a environment variable
In the shell language, all variables are global unless marked local.
It's a slightly confusing historical artifact that, inside the body
of a function, "typeset" is equivalent to "local", and outside the
body of a function, "local" is meaningless because you're already in
the global scope. Also, even local variables have what is called
dynamic scope; that is, they become global to functions called from
the function that first declared the variable local, unless/until
such a called function yet again declares that same name "local".
Environment variables are entirely different beasts. An environment
variable is a *copy* of a shell variable. When you say "export ..."
you are telling the shell to maintain that copy automatically, so that
when you change the shell variable you also change the environment.
You can even declare a local variable to be exported, in which case
(in zsh, anyway) changes to that local are copied into the environment
until the local scope ends, at which point the original global is
copied into the environment again (or, if there is no exported non-
local variable of that name, the environment copy is removed).
The environment is global in a different way, in that it is passed
along to new processes started by the shell. If that new process is
*another* shell, it copies those environment variables into its own
collection of variables and automatically marks those new variables
as "export" so that changes transparently affect its environment for
any further new processes started in turn by *that* shell.
This does not, however, have any effect on the environment of the
first shell that started this chain: environments are always copies.
Passed by value, not by reference, if you're familiar with those
---End of forwarded mail from "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
Messages sorted by: