Path: utzoo!attcan!uunet!lll-winken!ames!ncar!boulder!sunybcs!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.unix.wizards Subject: Re: Set parent env with csh script Message-ID: <9314@smoke.BRL.MIL> Date: 8 Jan 89 04:58:00 GMT References: <174@v7fs1.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 20 In article <174@v7fs1.UUCP> mvp@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).