author | berghofe |
Sat, 26 Sep 1998 16:13:05 +0200 | |
changeset 5578 | 7de426cf179c |
parent 4539 | 4227bd14dbe7 |
child 5815 | b4d4a97df438 |
permissions | -rwxr-xr-x |
3203 | 1 |
#!/bin/bash |
2292 | 2 |
# |
2308 | 3 |
# $Id$ |
4 |
# |
|
2292 | 5 |
# Basic Isabelle startup script. |
6 |
||
7 |
||
8 |
## settings |
|
9 |
||
2704 | 10 |
PRG=$(basename $0) |
11 |
||
2735
29434f9b95dd
even more robust and user friendly invocation (no longer requieres
wenzelm
parents:
2711
diff
changeset
|
12 |
ISABELLE_HOME=$(dirname $0)/.. |
29434f9b95dd
even more robust and user friendly invocation (no longer requieres
wenzelm
parents:
2711
diff
changeset
|
13 |
. $ISABELLE_HOME/lib/scripts/getsettings || \ |
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2768
diff
changeset
|
14 |
{ echo "$PRG probably not called from its original place!"; exit 2; } |
2292 | 15 |
|
16 |
||
17 |
## diagnostics |
|
18 |
||
19 |
function usage() |
|
20 |
{ |
|
21 |
echo |
|
22 |
echo "Usage: $PRG [OPTIONS] [INPUT] [OUTPUT]" |
|
23 |
echo |
|
24 |
echo " Options are:" |
|
2343 | 25 |
echo " -e MLTEXT pass MLTEXT to the ML session" |
2704 | 26 |
echo " -m MODE add print mode for output" |
2292 | 27 |
echo " -q non-interactive session" |
28 |
echo " -r open heap file read-only" |
|
4516 | 29 |
echo " -u pass 'use\"ROOT.ML\";' to the ML session" |
3502 | 30 |
echo " -w reset write permissions on OUTPUT" |
2292 | 31 |
echo |
3184 | 32 |
echo " INPUT (default \"$ISABELLE_LOGIC\") and OUTPUT specify in/out heaps." |
2292 | 33 |
echo " These are either names to be searched in the Isabelle path, or actual" |
4539 | 34 |
echo " file names (containing at least one /)." |
2768 | 35 |
echo " If INPUT is \"RAW_ML_SYSTEM\", just start the bare bones ML system." |
2292 | 36 |
echo |
37 |
exit 1 |
|
38 |
} |
|
39 |
||
40 |
function fail() |
|
41 |
{ |
|
2343 | 42 |
echo "$1" >&2 |
2292 | 43 |
exit 2 |
44 |
} |
|
45 |
||
46 |
||
47 |
## process command line |
|
48 |
||
49 |
# options |
|
50 |
||
51 |
MLTEXT="" |
|
2704 | 52 |
MODES="" |
2292 | 53 |
TERMINATE="" |
54 |
READONLY="" |
|
3502 | 55 |
NOWRITE="" |
2292 | 56 |
|
4516 | 57 |
while getopts "e:m:qruw" OPT |
2292 | 58 |
do |
59 |
case "$OPT" in |
|
60 |
e) |
|
61 |
MLTEXT="$MLTEXT $OPTARG" |
|
62 |
;; |
|
2704 | 63 |
m) |
64 |
if [ -z "$MODES" ]; then |
|
65 |
MODES="\"$OPTARG\"" |
|
66 |
else |
|
2711 | 67 |
MODES="\"$OPTARG\", $MODES" |
2704 | 68 |
fi |
69 |
;; |
|
2292 | 70 |
q) |
71 |
TERMINATE=true |
|
72 |
;; |
|
73 |
r) |
|
74 |
READONLY=true |
|
75 |
;; |
|
4516 | 76 |
u) |
77 |
MLTEXT="$MLTEXT use\"ROOT.ML\";" |
|
78 |
;; |
|
3502 | 79 |
w) |
80 |
NOWRITE=true |
|
81 |
;; |
|
2292 | 82 |
\?) |
83 |
usage |
|
84 |
;; |
|
85 |
esac |
|
86 |
done |
|
87 |
||
88 |
shift $(($OPTIND - 1)) |
|
89 |
||
90 |
||
91 |
# args |
|
92 |
||
93 |
INPUT="" |
|
94 |
OUTPUT="" |
|
95 |
||
96 |
if [ $# -ge 1 ]; then |
|
97 |
INPUT="$1" |
|
98 |
shift |
|
99 |
fi |
|
100 |
||
101 |
if [ $# -ge 1 ]; then |
|
102 |
OUTPUT="$1" |
|
103 |
shift |
|
104 |
fi |
|
105 |
||
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2768
diff
changeset
|
106 |
[ $# -ne 0 ] && { echo "Bad args: $*"; usage; } |
2292 | 107 |
|
108 |
||
109 |
## check ML system |
|
110 |
||
2308 | 111 |
[ -z "$ML_SYSTEM" ] && fail "Missing ML system settings! Unable to run Isabelle." |
2292 | 112 |
|
113 |
||
114 |
## input heap file |
|
115 |
||
3184 | 116 |
[ -z "$INPUT" ] && INPUT="$ISABELLE_LOGIC" |
2292 | 117 |
|
118 |
case "$INPUT" in |
|
2768 | 119 |
RAW_ML_SYSTEM) |
2292 | 120 |
INFILE="" |
121 |
;; |
|
122 |
*/*) |
|
123 |
INFILE="$INPUT" |
|
2343 | 124 |
[ ! -f "$INFILE" ] && fail "Bad heap file: \"$INFILE\"" |
2292 | 125 |
;; |
126 |
*) |
|
2308 | 127 |
ISA_PATH="" |
2292 | 128 |
INFILE="" |
129 |
for DIR in $(echo $ISABELLE_PATH | tr : " ") |
|
130 |
do |
|
2968 | 131 |
ISA_PATH="$ISA_PATH $DIR" |
132 |
[ -z "$INFILE" -a -f $DIR/$INPUT ] && INFILE=$DIR/$INPUT |
|
2292 | 133 |
done |
2308 | 134 |
if [ -z "$INFILE" ]; then |
2343 | 135 |
echo "Unknown logic \"$INPUT\" -- no heap file found in:" >&2 |
2308 | 136 |
for DIR in $ISA_PATH |
137 |
do |
|
2343 | 138 |
echo " $DIR" >&2 |
2308 | 139 |
done |
140 |
exit 2 |
|
141 |
fi |
|
2292 | 142 |
;; |
143 |
esac |
|
144 |
||
145 |
||
146 |
## output heap file |
|
147 |
||
148 |
case "$OUTPUT" in |
|
149 |
"") |
|
150 |
[ -z "$READONLY" -a -w "$INFILE" ] && OUTFILE="$INFILE" |
|
151 |
;; |
|
152 |
*/*) |
|
153 |
OUTFILE="$OUTPUT" |
|
154 |
;; |
|
155 |
*) |
|
3118 | 156 |
mkdir -p "$ISABELLE_OUTPUT" |
157 |
OUTFILE="$ISABELLE_OUTPUT/$OUTPUT" |
|
2292 | 158 |
;; |
159 |
esac |
|
160 |
||
161 |
||
4333 | 162 |
## prepare tmp directory |
163 |
||
164 |
[ -z "$ISABELLE_TMP_PREFIX" ] && ISABELLE_TMP_PREFIX=/tmp/isabelle |
|
165 |
||
166 |
ISABELLE_TMP="$ISABELLE_TMP_PREFIX$$" |
|
167 |
mkdir -p "$ISABELLE_TMP" |
|
168 |
||
169 |
||
2292 | 170 |
## run it! |
171 |
||
172 |
ML_SYSTEM_BASE=$(echo $ML_SYSTEM | cut -f1 -d-) |
|
173 |
||
2704 | 174 |
[ -n "$MODES" ] && MLTEXT="print_mode := [$MODES]; $MLTEXT" |
175 |
||
4333 | 176 |
export INFILE OUTFILE MLTEXT TERMINATE NOWRITE ISABELLE_TMP |
177 |
||
178 |
if [ -f $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM ]; then |
|
179 |
$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM |
|
180 |
else |
|
181 |
$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE |
|
182 |
fi |
|
4355 | 183 |
RC=$? |
4333 | 184 |
|
185 |
#Do not even think of 'rm -r'!! |
|
186 |
rmdir $ISABELLE_TMP |
|
4355 | 187 |
|
188 |
exit $RC |