Iconitis

Guy Harris guy at auspex.auspex.com
Wed Apr 19 17:10:56 AEST 1989


 >>That's rather odd, as you can't change environment variables from a
 >>unix command or shell script. The spawned process only sees a copy of
 >>the environment. Are you sure it wasn't MSDOS?
 >
 >You can do the same thing in MSDOS as you can in UNIX -- find the original
 >copy of the environment table and modify it.  It isn't too hard to do for
 >UNIX programs, especially shell scripts.

It isn't difficult for shell scripts to modify the environment of the
shell that's running the script.  It is *quite* difficult for shell
scripts to modify the environment of the shell that read the command to
run the script, since that shell isn't running in the same process as
the one running the script, and it is quite difficult for one process to
find the environment in another process - for one thing, it needs read/write
permission on "/dev/mem" and the swap device, or a "/proc"
implementation and read/write access on that process, or the ability to
"ptrace" that other process, or the active cooperation of that other
process.

The same applies to commands implemented as executable images rather
than shell scripts.

So, if you claim that you ran some ordinary program or shell script and
it modified the environment *of the shell at which you typed the
command* without the active cooperation of that shell (e.g., some
combination of "eval" and backquotes), you didn't see what you think you
saw - try again.



More information about the Comp.lang.c mailing list