On 17.08.2011 20:53, Stephane CHAZELAS wrote:
2011-08-17, 08:32(+02), Francky Leyn:
On 8/16/2011 10:53 PM, Stephane CHAZELAS wrote:
2) If VAR coincides with an environment variable, and in the
script I change it value, is this then propagated to outside
the script? Is the environment variable affected?
The environment is a list of strings (by convention of the format
[...]
In no circumstance are variable definitions in one process going
to affect the environment of other processes (an exception to
that is the "fish" shell)
Could it be that the two of you are not talking about the same thing?
Just for clarity: environment variables (henceforth "the environment")
of a process are (is) inherited by its children.
Therefore, what *does* happen, is that if Stephane, as in 2), changes
VAR in script, the change gets propagated to the scripts *child* processes.
$ X=1 bash 1*)
$ echo $X
1
$ X=2
$ bash
$ echo $X
2
But what does of course not happen, is that the change would get
propagated to the *parent* process.
$ export X=1 2*)
$ echo $X
1
$ bash
$ X=2
$ exit
$ echo $X
1
1*) X will exist only in the environment of the child process being started
2*) X will exist in the environment of the current process and will
therefore be inherited and exist in the environment of its children as well
(What is the "fish" shell ???)