Mail Archives: djgpp/1995/02/07/12:04:12
> 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 -