summaryrefslogtreecommitdiffstats
path: root/mantools/enter
blob: 4287c1a6cb00e5e57a5a1335397327d8eea23134 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/sh

# enter - set up project-specific environment

# @(#) enter.sh 1.5 11/4/89 15:56:03

# initialize

IFS=" 	
"

: ${HOME?} ${SHELL=/bin/sh} make sure these are set

# sanity checks...

test $# = 1 || { 
    echo "Usage: ${0} project" 1>&2; exit 1
}

test -r ${HOME}/.${1} || { 
    echo "${0}: can't read environment file: '${HOME}/.${1}'" 1>&2; exit 1
}

test -x ${SHELL} || { 
    echo "${0}: can't execute command shell: '${SHELL}'" 1>&2; exit 1
}

# set up default Bourne-shell prompt

export PS1; PS1="$1%${PS1- }"

# load environment 

. ${HOME}/.${1}

# define UPPER and lower-case environment variables with the project name

_PNAME_=`echo ${1} | case \`echo -n\` in		# assume $1 lower case
			"") tr a-z A-Z;;		# this is for V7, BSD
			 *) tr '[a-z]' '[A-Z]';;	# and this is for SYSV
		     esac`
eval ${1}=\${${_PNAME_}=\${${1}}}

eval test "X\${${1}}" != X || { 
    echo "${0}: ${HOME}/.${1} should set '${1}' or '${_PNAME_}'" 1>&2; exit 1
}

export ${1} MANPATH PATH ${_PNAME_}

# become a new shell

echo "Entering project '${1}' - leave with 'exit' or 'control-d'" 1>&2

exec ${SHELL} 

echo "project ${1} NOT entered" 1>&2; exit 1;

#++
# NAME
#	enter 1
# SUMMARY
#	set up a project-specific environment
# PROJECT
#	sdetools
# SYNOPSIS
#	enter project
#	exit
# DESCRIPTION
#	The \fIenter\fR command sets up an environment that makes
#	it easy to access \fIproject\fR-specific programs and files.
#
#	\fIenter\fP consults a file with environment information
#	($HOME/.\fIproject\fR, Bourne-shell syntax) and invokes 
#	a new command shell of the same type as the login shell.
#	Typically, project environment files are maintained and 
#	given out by the project administrator.
#
#	In order to leave the project environment use the \fIexit\fP 
#	command or type a control-d;
#	the details may depend on the type of login shell involved.
#
#	As a minimum, the environment file should set an environment
#	variable with the same name as the \fIproject\fP. The variable 
#	name can be either be identical to \fIproject\fP or in upper case.
#	For consistency, \fIenter\fP will set both variables to the same value.
# EXAMPLE
# .fi
# .ad
#	In this example, 
#	all files pertaining to a project \fIfoobar\fR are located under the
#	directory \fI/usr/foo/bar/foobar\fR. For example, there
#	are subdirectories
#	\fI/usr/foo/bar/foobar/man\fR with manual pages, 
#	\fI/usr/foo/bar/foobar/bin\fR with executable 
#	programs, other directories for object libraries and include files, 
#	and so on.
#
#	In order to enter a project \fIfoobar\fR, the command
# .PP
# .ti +5
# .ft C
#	enter foobar
# .ft 
# .PP
#	consults a file \fI.foobar\fR (in the user\'s home directory) 
#	with contents:
# .PP
# .ft C
# .nf
# .in +5
#	export FOOBAR;	FOOBAR=/usr/foo/bar/foobar
#	export PATH;	PATH=$PATH:$FOOBAR/bin
#	export MANPATH;	MANPATH=$MANPATH:$FOOBAR/man
# .ft 
# .fi
# .PP
#	The second line automatically makes all project-specific 
#	executable programs accessible. The third line makes it possible 
#	to use the standard UNIX \fIman\fR command for retrieval of 
#	project-specific manual pages. The \fIenter\fR command
#	makes sure that both the \fIfoobar\fR and \fIFOOBAR\fR
#	environment variables are set to the same value.
# COMMANDS
#	sh(1), echo(1), test(1), tr(1), login shell
# FILES
#	$HOME/.\fIproject\fR
# ENVIRONMENT VARIABLES
#	SHELL, login shell
#	HOME, login directory
#	PATH, search path for commands
#	MANPATH, search path for the \fIman\fR command.
# BUGS
#	Name clashes may occur if people have entered several projects
#	at the same time. This can be avoided by using unique project names,
#	which is a good idea anyway.
# AUTHOR(S)
#	W.Z. Venema
#	Eindhoven University of Technology
#	Department of Mathematics and Computer Science
#	Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
# CREATION DATE
#	Tue Apr 19 15:35:41 MET DST 1988
# STATUS
#	enter.sh 1.5 11/4/89 15:56:03 (draft)
#--