Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!batcomputer!itsgw!steinmetz!uunet!ubvax!mrspoc!itkin From: itkin@mrspoc.UUCP (Steven M. List) Newsgroups: comp.unix.xenix Subject: Re: Changing the environment in sh Keywords: sh export shell Message-ID: <423@mrspoc.UUCP> Date: 4 Sep 88 01:07:00 GMT References: <59@csnz.nz> Reply-To: itkin@mrspoc (Steven M. List) Organization: Transact Software, Inc., Mt. View, CA Lines: 19 In article <59@csnz.nz> paul@csnz.UUCP (Paul Gillingwater) writes: > I've Read The FM's, but I must be a bit dim - how do I change an > environment variable, e.g. PATH, using a /bin/sh script, and have > those changes effective in my login shell? > You're not dim, just apparently a novice with the shell. This is one of the first difficult lessons of shell programming. You cannot change the value of a variable (environment or otherwise) from a subshell, since the environment of a superior shell is not available to the subshell. The only way to do this is with the "." (dot) command which can loosely be understood to mean "read in the following file (using PATH if necessary) and execute it as if I had typed the commands directly into my keyboard". Of course, if you include the dot command in a shell script, it will execute the commands AS IF THEY WERE PART OF THE CALLING SCRIPT. There is NO OTHER WAY to change shell environment variables. -- * Steven List @ Transact Software, Inc. * {coherent,mips,ubvax}!mrspoc!itkin * Voice: (415) 961-6112