home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!nntp1.radiomail.net!fernwood!autodesk!dls
- From: dls@Autodesk.COM (Daniel Louis Smith)
- Newsgroups: comp.unix.shell
- Subject: Re: Setting enviroment variables in a shell script
- Keywords: environment variables shell script
- Message-ID: <18469@autodesk.COM>
- Date: 25 Jan 93 19:36:24 GMT
- References: <35774@sales.GBA.NYU.EDU> <1993Jan25.003213.3784@lri.fr>
- Organization: Autodesk Inc., Sausalito CA, USA
- Lines: 44
-
- In <1993Jan25.003213.3784@lri.fr> wacren@lri.fr (Laurent WACRENIER) writes:
-
-
- > In article <35774@sales.GBA.NYU.EDU>, elouie@sales.GBA.NYU.EDU (Euge) writes:
- > |> How do you set an environment variable in a C-Shell script? I tried
- > |> setenv enviroment_variable value, but as soon as the script finishes,
- > |> the value of the varialbe is reset to its original value. My guess is
-
- My favorite way is to source bits of csh... example:
-
- bermuda:dls/bin (1) :-) alias newdir
- set newdir_attempt=(!*); source $HOME/bin/newdir_csh
-
- bermuda:dls/bin (1) :-) cat newdir_csh
- #!/bin/echo sorry,try:source
- if ($#newdir_attempt == 0) then
- echo 'usage: newdir dir_to_make [files to move to dir_to_make]'
- goto nd_end
- endif
-
- mkdir $newdir_attempt[1] || goto nd_end
- set cd_attempt=$newdir_attempt[1]
- if ($#newdir_attempt > 1) then
- shift newdir_attempt
- mv -f $newdir_attempt $cd_attempt
- unset newdir_attempt
- endif
- pl $cd_attempt # this is a pushd and ls alias
-
- nd_end:
- bermuda:dls/bin (1) :-)
-
- Now note that I haven't mentioned environment variables yet. It
- doesn't matter - the idea is to set up an alias which sets a variable
- which gets passed to a csh script which is *sourced*. You can change
- whatever you need to (csh or env vars) this way.
-
- Daniel
-
-
- --
- dls@autodesk.com dansmith@well.sf.ca.us
- Daniel L Smith, Autodesk, Sausalito, California, (415) 332-2344 x 2580
- formerly dansmith@autodesk.com, changed my login recently
-