Set parent env with csh script

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Jan 8 14:58:00 AEST 1989


In article <174 at v7fs1.UUCP> mvp at v7fs1.UUCP (Mike Van Pelt) writes:
>I would like to write a shell script (csh preferred) that will
>set a few environment variables to various things.  Of course,
>just doing   setenv foo bar  in the script only works for that
>subshell and its children, not for the calling shell.  I've
>gone back and forth through all the likely places in the manuals,
>and haven't found any mention of this.

It's implicit in the description of how environment variables work.

>Is it possible for a subshell to changes the calling shell's 
>environment?  How?

There is no official way for a subprocess to alter an ancestor
process's environment.  Specialized ways can be devised.  In
your case, however, probably all you need is to realize that
SOURCING a shell script (as opposed to EXECUTING it) causes the
changes to occur in the invoking shell context (as opposed to
a subprocess context).  Thus you can alter environment variable
via a sourced script that does setenv (or Bourne shell equivalent).



More information about the Comp.unix.wizards mailing list