www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/02/07/12:04:12

To: Bill Davidson <bdavidson AT ra DOT isisnet DOT com>
Cc: Long Doan <ldoan1 AT osf1 DOT gmu DOT edu>, djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: putenv() and system()
Date: Tue, 07 Feb 95 11:09:25 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>

> what I was getting at.  I have always thought that this was a peculiarity 
> of DOS, which doesn't like you messing with the master environment block 
> (yes, I know it can be done, but I also know how difficult it is).  I 

I know that much.  I didn't want for system() to change the master
environment, though.  As system() is usually implemented by calling
a subsidiary shell which is then passed the command line you specify
as the argument to system(), is it too much to expect that the child
of that subsidiary shell inherits all the environment variables of 
the parent, i.e. the program which called system() in the first
place?

> Getting back to your original post, could you try something like:
>	system("set var_to_change=new value");
>	system("do_something");

No, this won't work, and I don't expect it to.  It won't work under
Unix, either, because the first system() only affects the 
environment of the shell born to execute that ``set'' command, and
that environment dies right after ``set'' is executed.  The next
system() invokes a new instance of the shell, which doesn't know
about the new value of var_to_change.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019