1 #!/bin/sh 2 3 # enter - set up project-specific environment 4 5 # @(#) enter.sh 1.5 11/4/89 15:56:03 6 7 # initialize 8 9 IFS=" 10 " 11 12 : ${HOME?} ${SHELL=/bin/sh} make sure these are set 13 14 # sanity checks... 15 16 test $# = 1 || { 17 echo "Usage: ${0} project" 1>&2; exit 1 18 } 19 20 test -r ${HOME}/.${1} || { 21 echo "${0}: can't read environment file: '${HOME}/.${1}'" 1>&2; exit 1 22 } 23 24 test -x ${SHELL} || { 25 echo "${0}: can't execute command shell: '${SHELL}'" 1>&2; exit 1 26 } 27 28 # set up default Bourne-shell prompt 29 30 export PS1; PS1="$1%${PS1- }" 31 32 # load environment 33 34 . ${HOME}/.${1} 35 36 # define UPPER and lower-case environment variables with the project name 37 38 _PNAME_=`echo ${1} | case \`echo -n\` in # assume $1 lower case 39 "") tr a-z A-Z;; # this is for V7, BSD 40 *) tr '[a-z]' '[A-Z]';; # and this is for SYSV 41 esac` 42 eval ${1}=\${${_PNAME_}=\${${1}}} 43 44 eval test "X\${${1}}" != X || { 45 echo "${0}: ${HOME}/.${1} should set '${1}' or '${_PNAME_}'" 1>&2; exit 1 46 } 47 48 export ${1} MANPATH PATH ${_PNAME_} 49 50 # become a new shell 51 52 echo "Entering project '${1}' - leave with 'exit' or 'control-d'" 1>&2 53 54 exec ${SHELL} 55 56 echo "project ${1} NOT entered" 1>&2; exit 1; 57 58 #++ 59 # NAME 60 # enter 1 61 # SUMMARY 62 # set up a project-specific environment 63 # PROJECT 64 # sdetools 65 # SYNOPSIS 66 # enter project 67 # exit 68 # DESCRIPTION 69 # The \fIenter\fR command sets up an environment that makes 70 # it easy to access \fIproject\fR-specific programs and files. 71 # 72 # \fIenter\fP consults a file with environment information 73 # ($HOME/.\fIproject\fR, Bourne-shell syntax) and invokes 74 # a new command shell of the same type as the login shell. 75 # Typically, project environment files are maintained and 76 # given out by the project administrator. 77 # 78 # In order to leave the project environment use the \fIexit\fP 79 # command or type a control-d; 80 # the details may depend on the type of login shell involved. 81 # 82 # As a minimum, the environment file should set an environment 83 # variable with the same name as the \fIproject\fP. The variable 84 # name can be either be identical to \fIproject\fP or in upper case. 85 # For consistency, \fIenter\fP will set both variables to the same value. 86 # EXAMPLE 87 # .fi 88 # .ad 89 # In this example, 90 # all files pertaining to a project \fIfoobar\fR are located under the 91 # directory \fI/usr/foo/bar/foobar\fR. For example, there 92 # are subdirectories 93 # \fI/usr/foo/bar/foobar/man\fR with manual pages, 94 # \fI/usr/foo/bar/foobar/bin\fR with executable 95 # programs, other directories for object libraries and include files, 96 # and so on. 97 # 98 # In order to enter a project \fIfoobar\fR, the command 99 # .PP 100 # .ti +5 101 # .ft C 102 # enter foobar 103 # .ft 104 # .PP 105 # consults a file \fI.foobar\fR (in the user\'s home directory) 106 # with contents: 107 # .PP 108 # .ft C 109 # .nf 110 # .in +5 111 # export FOOBAR; FOOBAR=/usr/foo/bar/foobar 112 # export PATH; PATH=$PATH:$FOOBAR/bin 113 # export MANPATH; MANPATH=$MANPATH:$FOOBAR/man 114 # .ft 115 # .fi 116 # .PP 117 # The second line automatically makes all project-specific 118 # executable programs accessible. The third line makes it possible 119 # to use the standard UNIX \fIman\fR command for retrieval of 120 # project-specific manual pages. The \fIenter\fR command 121 # makes sure that both the \fIfoobar\fR and \fIFOOBAR\fR 122 # environment variables are set to the same value. 123 # COMMANDS 124 # sh(1), echo(1), test(1), tr(1), login shell 125 # FILES 126 # $HOME/.\fIproject\fR 127 # ENVIRONMENT VARIABLES 128 # SHELL, login shell 129 # HOME, login directory 130 # PATH, search path for commands 131 # MANPATH, search path for the \fIman\fR command. 132 # BUGS 133 # Name clashes may occur if people have entered several projects 134 # at the same time. This can be avoided by using unique project names, 135 # which is a good idea anyway. 136 # AUTHOR(S) 137 # W.Z. Venema 138 # Eindhoven University of Technology 139 # Department of Mathematics and Computer Science 140 # Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands 141 # CREATION DATE 142 # Tue Apr 19 15:35:41 MET DST 1988 143 # STATUS 144 # enter.sh 1.5 11/4/89 15:56:03 (draft) 145 #-- 146