home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / shell / 3100 < prev    next >
Encoding:
Text File  |  1992-07-22  |  1.5 KB  |  37 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!murphy!jpradley!jpr
  3. From: jpr@jpradley.jpr.com (Jean-Pierre Radley)
  4. Subject: Re: setting variable from script to current environment??
  5. Organization: Unix in NYC
  6. Date: Wed, 22 Jul 1992 01:48:34 GMT
  7. Message-ID: <1992Jul22.014834.1384@jpradley.jpr.com>
  8. References: <1992Jul21.070212.16485@gbrmpa.gov.au>
  9. Lines: 26
  10.  
  11. In article <1992Jul21.070212.16485@gbrmpa.gov.au> wayne@gbrmpa.gov.au (Wayne Amisano) writes:
  12. >Hi,
  13. >
  14. >I am trying to write a script to set an environment variable in
  15. >my tcsh environment.  I could use an alias to do it, but would
  16. >much rather do it from a script.  What i need to do is, run a
  17. >script to change the value of one environment variable, but
  18. >every time i do this, it changes the variable in the spawned
  19. >process, but it then disappears when it dies.
  20. >
  21. >I need this variable to remain around!!  Any ideas would be welcome.
  22.  
  23. It is an IMPERATIVE in unix that a child process CANNOT change the environment
  24. of its parents. You should seek to understand this why this is necessary.
  25.  
  26. If you have a script that sets variables, running the script will never set
  27. those variables for the calling shell, its parent.
  28.  
  29. If you "source script" (csh, tcsh), or ". script" (sh, ksh), then yes, you can
  30. set variables that way.
  31.  
  32. Running a script spawns a new process. Sourcing a script interprets its
  33. commands within the current shell just as if you'd typed them from the shell
  34. prompt.
  35. -- 
  36. Jean-Pierre Radley   Unix in NYC   jpr@jpr.com   jpradley!jpr   CIS: 72160,1341
  37.