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