|
|
1.1 root 1: : 'Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984, 1985.'
2: : '$Header: b.sh.gen,v 1.1 85/08/22 14:33:39 timo Exp $'
3: :
4: : 'Shell script to start B'
5: :
6:
7: IFS=
8: PATH=/bin:/usr/bin:/usr/ucb:/usr/local:/usr/new
9: export PATH
10:
11: : 'Most variables use the construct ${var=default}, meaning that they'
12: : 'are set to "default" only when they do not have a value initially.'
13: : 'The user can override by setting these variables in the environment'
14:
15: : 'B_LIB is the directory where b finds auxiliary binaries and data files.'
16: : 'Filled in by make.'
17: B_LIB=
18: : 'BINT determines whether bint or bsmall will be used as interpreter.'
19: : 'Filled in by ../../Setup.'
20: BINT=
21:
22: : 'B_INTERPRETER is the binary of the interpreter (passed to the editor)'
23: : ${B_INTERPRETER=$B_LIB/$BINT}
24: export B_INTERPRETER
25:
26: : 'B_MESSAGES is where the interpreter finds its error messages'
27: : ${B_MESSAGES=$B_LIB/Messages}
28: export B_MESSAGES
29:
30: : 'BEDITOR is the B editor to be used (must be a B editor, not vi etc.)'
31: : ${BEDITOR=$B_LIB/bed}
32: export BEDITOR
33:
34: : 'BED_LIB is used by the B editor to find various files'
35: : ${BED_LIB=$B_LIB}
36: export BED_LIB
37:
38: : 'BED_HELP is where the B editor finds its help file'
39: : ${BED_HELP=$BED_LIB/Bed_help}
40: export BED_HELP
41:
42: : 'LPR is the lineprinter spooler'
43: LPR=lpr
44:
45: : 'MKSUGG makes the suggestion file for the editor'
46: MKSUGG=$B_LIB/mksugg
47:
48: : 'CONV creates a .b_perm with all B-units and targets found in it'
49: CONV=$B_LIB/convert
50:
51: : 'Test for TERMCAP. Give default only if there is no /etc/termcap'
52: case $TERMCAP in
53: '') if test -f /etc/termcap
54: then : 'No need to set termcap'
55: else
56: TERMCAP=$B_LIB/termcap
57: export TERMCAP
58: fi;;
59: esac
60:
61: : 'Subroutine to print an error message for b -i/-o and exit'
62: IO_ERR='echo \
63: "*** There is something I don'\''t quite get in your call of $0
64: $0 $1
65: `echo $0 $1|sed s/./\ /g`^
66: *** The problem is: no target where expected"
67: exit 1'
68:
69: : 'Convert old workspace format to new'
70: if test ! -f .b_perm -a -f [\"\'\<\>=]?*
71: then
72: if test -f .prmnv
73: then
74: echo '
75: *** Just a moment! It seems you have never used this version of B before in
76: *** this workspace. While you are reading this message, I will convert it
77: *** to one with which the new B interpreter is more happy.
78: ***
79: *** One warning: the converted workspace is no longer compatible with the
80: *** old version of B. If you want to use that version in this workspace
81: *** lateron, you will have to move the file ".prmnv_save" back to ".prmnv".
82: *** The shell command "mv .prmnv_save .prmnv" will accomplish this.
83: *** However, if you do this, you will loose any permanent targets created
84: *** or modified while using the new version, so please make up your mind.
85: '
86: else
87: echo '*** [Recovering lost permanent environment information]'
88: fi
89: if test -f =????????????*
90: then
91: echo '*** [Warning -- long target names may be truncated]'
92: fi
93: $CONV [\"\'\<\>=]?*
94: fi
95:
96: case $1 in
97: '') if test -t 0 -a -t 1 # -a -t 2
98: then
99: $MKSUGG
100: exec $BEDITOR
101: else
102: exec $B_INTERPRETER
103: fi;;
104: -e) BEDITOR=${EDITOR-/usr/ucb/vi}; export BEDITOR; exec $B_INTERPRETER;;
105: -v) BEDITOR=/usr/ucb/vi; export BEDITOR; exec $B_INTERPRETER;;
106: -i) case $2 in
107: '') eval "$IO_ERR";;
108: *) {
109: echo "PUT {} IN $2"
110: echo "WHILE 1=1: READ $2[#$2 + 1] RAW"
111: cat $3
112: } | $B_INTERPRETER >/dev/null 2>&1
113: : '(No output because there is always a complaint about EOF)'
114: ;;
115: esac
116: ;;
117: -o) case $2 in
118: '') eval "$IO_ERR";;
119: *) {
120: echo "FOR l'i'n'e\" IN $2:"
121: echo " WRITE l'i'n'e\" /"
122: echo "DELETE l'i'n'e\""
123: } | $B_INTERPRETER >$3
124: ;;
125: esac
126: ;;
127: -p) $B_LIB/b_p|$LPR;;
128: -l) exec $B_LIB/b_p;;
129: *) if test -f "$1"
130: then exec $B_INTERPRETER "$@" -q
131: else
132: case $SHELL in
133: */csh) B=`basename $0`;;
134: *) B="$0";;
135: esac
136: echo 'To enter '$B' type "'$B'"
137: to enter '$B' with the '`basename "${EDITOR-vi}"`' editor, type "'$B' -e"'
138: case $EDITOR in
139: ''|vi|*/vi) ;;
140: *) echo 'to enter '$B' with the vi editor, type "'$B' -v"';;
141: esac
142: echo 'to execute commands from a file, type "'$B' file"
143: to input lines from a file to a text-table, type "'$B' -i table-name file"
144: to output lines from a text-table to a file, type "'$B' -o table-name file"
145: to print units on the line printer, type "'$B' -p"
146: to print units on the terminal, type "'$B' -l"' >&2
147: exit 1
148: fi;;
149: esac
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.