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