[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Changing parent process environment.....



On 28 Feb 1999, in message <000501be62b4$a8e0e960$8980c6d1 computer1>
  "Bill Waters" <wwwaters prismnet com> wrote:
| Is it possible by any means (shell script, perl, c) possibly using system
| calls
| to make changes to a parent process environment......

No.

| I know it can be done
| from the command line (in other words, not starting a child process).

That's not changing the parent, that's changing the _current_ process.

| It seems to be a reasonable expectation.....

Alas, no, it's not. It opens too many problems. Chaos and hackery would ensue
if a process were subject to arbitrary change by its children.

| I'd like to write a script or a program (my own
| command...not an alias) to modify the environment variables as needed for a
| given situation....any ideas or obvious oversights????

Why not an alias?

All the usual solutions to this issue revolve around getting the current
shell to do things, and that usually means an alias or a shell function.

I do just what you describe (I believe). I have a program called setvar
(in perl) whose purpose is to do environment configuration. I use it to
invoke other things in special ways, and also to ajust the current
shell's environment. To this latter end it has a mode where it emits on
stdout shell comands to make the necessary changes. My shell then has
two shell functions set up:

    var(){		eval `setvar -x -n -f ${1+"$@"}`; }
    use(){		eval `setvar -x -n -f "use $*"`; }

The former sets particular variables, the latter is for classes of variables
(eg I just type "use web" to set web-related things). You can get and examine
setvar from my web page, under the "scripts" section.
--
Cameron Simpson, DoD#743        cs zip com au        http://www.zip.com.au/~cs/

Many companies are just now realizing that testing for the year 2000
problems will likely be more time-consuming and expensive than the
fix-it phase.	- Bob Evans, Information Week, September 1997



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]