On Tue, 26 Nov 2002, Tino Wildenhain wrote:
> Tried it:
> >>> os.environ['MYENVIRON']='FooBar'
> ^D
> ^^^^ nothing.
> What is wrong?

rdmurray@stage:~>cat temp.sh
export TEST='abc'
echo $TEST
rdmurray@stage:~>sh temp.sh
rdmurray@stage:~>echo $TEST

^^^^^ equally nothing.

export (and the equivalent python above) sets the environment
variable in the current process environment space, *not* the parent
(that's a *much* trickier operation).  The obverse (TEST='abc'
somecommandhere) sets the environment variable only in the *sub*process
environment space (the one being created) and does not affect the
current process.  The python equivalent of *that* would be to supply
a modified *copy* of the ENVIRON dict to execve or similar.

To do the python equivalent of what happens when you set a variable
in a script *without* using export (the current process environment
is changed but the change is not passed to subprocesses), you'd
have to make a copy of the environ before modifying it, and pass
*that* to execve or equivalent.


Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to