A simple C-shell query.

Leif Andersson leif at control.lth.se
Mon Nov 19 01:22:47 AEST 1990


>>>>> On 16 Nov 90 19:26:46 GMT, lubkt at vax1.cc.lehigh.edu said:

lubkt> Here is a C-shell query:
   [stuff deleted]
lubkt> You might get an idea, if I tell you its application. I have TeX
lubkt> compiled under SunOS. I do not to define all the environment variables
lubkt> (variables set using setenv) for all users, only those who want to use
lubkt> tex, by enter, say, "use tex", where "use" is a C-shell script which
lubkt> takes "tex" as its parameter. Having a general script like this will
lubkt> permit "use" to be as generic as possible.

The solution we use to exactly this problem involves one alias and one
source'd script, but I still think it works quite well. The alias is:

  alias setup 'set setup=(\!*);source /usr/local/lib/setup.csh'

This line is put in each user's .cshrc or in a common file sourced by .cshrc.
The script referred to in the alias follows my signature. A user
wanting to use TeX puts the command "setup tex" in his .login  or
gives it interactively.

The system administrator puts in more "if ($setup[1] == whatever) then"
statements in the setup file when new software packages arrive,  and
we thus have a unified approach to selecting environment variables.

-------------------------------------------------------------------------------
 Leif Andersson				Internet: leif at Control.LTH.Se
 Dept. of Automatic Control             Bitnet:   BODELA at SELDC51
 Lund Institute of Technology           Phone:    +46 46 109742
 P.O. Box 118                           Fax:      +46 46 138118
 S-221 00 Lund, Sweden
-------------------------------------------------------------------------------

# SETUP --
 
while (${#setup} != 0)
  if ($setup[1] == tex) then
    set TEX=/usr/local/tex
    if ($?MYTEXINPUTS == 0) then  # The user gets his own path appended.
     setenv MYTEXINPUTS .
    endif
    setenv TEXSYSINPUTS $TEX/inputs:$TEX/inputs/bibtex
    setenv TEXINPUTS $MYTEXINPUTS\:$TEXSYSINPUTS
    setenv TEXFORMATS $TEX/formats
    setenv TEXFONTS $TEX/fonts:$TEX/fonts/vftfm

  else if ($setup[1] == metafont) then
    set TEX=/usr/local/tex
    setenv MFSYSINPUTS $TEX/mf/inputs:$TEX/mf/cm
    setenv MFINPUTS .:$MFSYSINPUTS
    setenv MFBASES $TEX/formats

  else if ($setup[1] == ssim) then
    setenv GPPATH "/usr/local/ssim/Src/lib"
  
  else if ($setup[1] == basile) then
    setenv BASILE_DIR "/usr/local/basile"

  else if ($setup[1] == muse) then
    setenv ELIBDIR /sperry/muse/lib/emacs
    setenv EMACS /sperry/muse/bin/emacs
    setenv EPATH $ELIBDIR/maclib
  
  else
    echo "Unknown setup: $setup"
  endif

  shift setup
end # while



More information about the Comp.unix.shell mailing list