Path: utzoo!attcan!uunet!lll-winken!ames!killer!dcs!wnp From: wnp@dcs.UUCP (Wolf N. Paul) Newsgroups: comp.unix.wizards Subject: Re: Set parent env with csh script Message-ID: <289@dcs.UUCP> Date: 8 Jan 89 05:57:26 GMT References: <174@v7fs1.UUCP> Reply-To: wnp@dcs.UUCP (Wolf N. Paul) Organization: DCS, Dallas, Texas Lines: 32 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. > >Is it possible for a subshell to changes the calling shell's >environment? How? No, it is not possible for a process to change its parent's environment. But what you propose can be accomplished by running the shell script via "source" (under csh) or "." (under sh or ksh). Thus, you can put your "setenv" statements into a script, and then call the script like this: % source scriptname or $ . scriptname If you don't want to remember this special invocation, create an alias (under csh, alias scriptname "source scriptname"), or a shell function (under sh or ksh) to call it. -- Wolf N. Paul * 3387 Sam Rayburn Run * Carrollton TX 75007 * (214) 306-9101 UUCP: killer!dcs!wnp ESL: 62832882 DOMAIN: dcs!wnp@killer.dallas.tx.us TLX: 910-380-0585 EES PLANO UD