Article View: comp.unix.shell
Article #118Re: setting variable from script to current environment??
From: Jean-Pierre Radley
Date: Wed, 22 Jul 1992 01:48
Date: Wed, 22 Jul 1992 01:48
26 lines
1558 bytes
1558 bytes
In article <1992Jul21.070212.16485@gbrmpa.gov.au> wayne@gbrmpa.gov.au (Wayne Amisano) writes: >Hi, > >I am trying to write a script to set an environment variable in >my tcsh environment. I could use an alias to do it, but would >much rather do it from a script. What i need to do is, run a >script to change the value of one environment variable, but >every time i do this, it changes the variable in the spawned >process, but it then disappears when it dies. > >I need this variable to remain around!! Any ideas would be welcome. It is an IMPERATIVE in unix that a child process CANNOT change the environment of its parents. You should seek to understand this why this is necessary. If you have a script that sets variables, running the script will never set those variables for the calling shell, its parent. If you "source script" (csh, tcsh), or ". script" (sh, ksh), then yes, you can set variables that way. Running a script spawns a new process. Sourcing a script interprets its commands within the current shell just as if you'd typed them from the shell prompt. -- Jean-Pierre Radley Unix in NYC jpr@jpr.com jpradley!jpr CIS: 72160,1341
Technical Details
Message-ID:
<1992Jul22.014834.1384@jpradley.jpr.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!murphy!jpradley!jprReferences:
<1992Jul21.070212.16485@gbrmpa.gov.au>Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.shell Path: arc1-ca.pugleaf.net!sparky!uunet!murphy!jpradley!jpr From: jpr@jpradley.jpr.com (Jean-Pierre Radley) Subject: Re: setting variable from script to current environment?? Organization: Unix in NYC Date: Wed, 22 Jul 1992 01:48:34 GMT Message-ID: <1992Jul22.014834.1384@jpradley.jpr.com> References: <1992Jul21.070212.16485@gbrmpa.gov.au> Lines: 26