[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: setenv
Shlomi Fish wrote:
>
> Well, just a note, in sh-like shells (such as GNU bash) you simply use > the "VAR=VALUE" command.For example, to assign the value "Hello" to > the environment variable MYVAR type the following line:
> MYVAR=Hello
You must also export.
> One of the big differences between csh (C-Shell) and sh (Bourne shell) > like shells is that sh uses the environment variables as program > variables, while csh keeps its own separate set of variables (which > are set by "SET VAR=VAL"). However, in order to pass values to a child > shell script I think one needs to use the setenv/getenv syntax.
In C-shell. In Bourne-shell (et al.) you must export to copy from the
variable space to the environmetn space.
> BTW, I always wondered if it's possible to write a program or a script > that will set one of the environment variables in the parent process > (i.e. the shell that executes it). Since I now realize that all the > shells use built-in commands in order to modify the environment > variables, maybe it isn't possible as I thought.
The real problem is accessing another process' (even the parent
process') memory space. The fork COPIES the environment space (along
with the rest of the memory map) into a NEW memory space belonging to
the new process. Since different processes' memory maps are shuffled in
and out of virtual memory WITHOUT notifying other processes, there is no
way to get at the parent process' environment space - it might very well
be swapped out to disk at the time you want to write into it from the
child process.
> Shlomi Fish
--
Eliyahu Skoczylas <eliyahu@photonet.com> Internationalization Coord.
PictureVision, Ltd. R&D for the PhotoNet - "Your Photos on the Net"
http://www.photonet.com/ "With PhotoNet,every camera's a digital camera"
References: