author | kleing |
Thu, 07 Dec 2000 16:21:47 +0100 | |
changeset 10624 | 850fdf9ce787 |
parent 10585 | 58a1ed1edb65 |
child 10905 | e23abeef8150 |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2292 | 2 |
# |
2308 | 3 |
# $Id$ |
9786 | 4 |
# Author: Markus Wenzel, TU Muenchen |
5 |
# License: GPL (GNU GENERAL PUBLIC LICENSE) |
|
2308 | 6 |
# |
2292 | 7 |
# Basic Isabelle startup script. |
8 |
||
9 |
||
10 |
## settings |
|
11 |
||
10511 | 12 |
PRG="$(basename "$0")" |
2704 | 13 |
|
10511 | 14 |
ISABELLE_HOME="$(dirname "$0")/.." |
9786 | 15 |
. "$ISABELLE_HOME/lib/scripts/getsettings" || \ |
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2768
diff
changeset
|
16 |
{ echo "$PRG probably not called from its original place!"; exit 2; } |
2292 | 17 |
|
18 |
||
19 |
## diagnostics |
|
20 |
||
21 |
function usage() |
|
22 |
{ |
|
23 |
echo |
|
24 |
echo "Usage: $PRG [OPTIONS] [INPUT] [OUTPUT]" |
|
25 |
echo |
|
26 |
echo " Options are:" |
|
10104 | 27 |
echo " -C tell ML system to copy output image" |
5815 | 28 |
echo " -I startup Isar interaction mode" |
9982 | 29 |
echo " -P startup Proof General interaction mode" |
8359
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
7887
diff
changeset
|
30 |
echo " -c tell ML system to compress output image" |
2343 | 31 |
echo " -e MLTEXT pass MLTEXT to the ML session" |
2704 | 32 |
echo " -m MODE add print mode for output" |
2292 | 33 |
echo " -q non-interactive session" |
34 |
echo " -r open heap file read-only" |
|
4516 | 35 |
echo " -u pass 'use\"ROOT.ML\";' to the ML session" |
3502 | 36 |
echo " -w reset write permissions on OUTPUT" |
2292 | 37 |
echo |
3184 | 38 |
echo " INPUT (default \"$ISABELLE_LOGIC\") and OUTPUT specify in/out heaps." |
7887 | 39 |
echo " These are either names to be searched in the Isabelle path, or" |
40 |
echo " actual file names (containing at least one /)." |
|
2768 | 41 |
echo " If INPUT is \"RAW_ML_SYSTEM\", just start the bare bones ML system." |
2292 | 42 |
echo |
43 |
exit 1 |
|
44 |
} |
|
45 |
||
46 |
function fail() |
|
47 |
{ |
|
2343 | 48 |
echo "$1" >&2 |
2292 | 49 |
exit 2 |
50 |
} |
|
51 |
||
52 |
||
53 |
## process command line |
|
54 |
||
55 |
# options |
|
56 |
||
10104 | 57 |
COPYDB="" |
9972 | 58 |
ISAR=false |
59 |
PROOFGENERAL="" |
|
8359
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
7887
diff
changeset
|
60 |
COMPRESS="" |
2292 | 61 |
MLTEXT="" |
2704 | 62 |
MODES="" |
2292 | 63 |
TERMINATE="" |
64 |
READONLY="" |
|
3502 | 65 |
NOWRITE="" |
2292 | 66 |
|
10104 | 67 |
while getopts "CIPce:m:qruw" OPT |
2292 | 68 |
do |
69 |
case "$OPT" in |
|
10104 | 70 |
C) |
71 |
COPYDB=true |
|
72 |
;; |
|
5815 | 73 |
I) |
9972 | 74 |
ISAR=true |
75 |
;; |
|
76 |
P) |
|
77 |
PROOFGENERAL=true |
|
5815 | 78 |
;; |
8359
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
7887
diff
changeset
|
79 |
c) |
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
7887
diff
changeset
|
80 |
COMPRESS=true |
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
7887
diff
changeset
|
81 |
;; |
2292 | 82 |
e) |
83 |
MLTEXT="$MLTEXT $OPTARG" |
|
84 |
;; |
|
2704 | 85 |
m) |
86 |
if [ -z "$MODES" ]; then |
|
87 |
MODES="\"$OPTARG\"" |
|
88 |
else |
|
10585 | 89 |
MODES="\"$OPTARG\", $MODES" |
2704 | 90 |
fi |
91 |
;; |
|
2292 | 92 |
q) |
93 |
TERMINATE=true |
|
94 |
;; |
|
95 |
r) |
|
96 |
READONLY=true |
|
97 |
;; |
|
4516 | 98 |
u) |
99 |
MLTEXT="$MLTEXT use\"ROOT.ML\";" |
|
100 |
;; |
|
3502 | 101 |
w) |
102 |
NOWRITE=true |
|
103 |
;; |
|
2292 | 104 |
\?) |
105 |
usage |
|
106 |
;; |
|
107 |
esac |
|
108 |
done |
|
109 |
||
110 |
shift $(($OPTIND - 1)) |
|
111 |
||
112 |
||
113 |
# args |
|
114 |
||
115 |
INPUT="" |
|
116 |
OUTPUT="" |
|
117 |
||
9786 | 118 |
if [ "$#" -ge 1 ]; then |
2292 | 119 |
INPUT="$1" |
120 |
shift |
|
121 |
fi |
|
122 |
||
9786 | 123 |
if [ "$#" -ge 1 ]; then |
2292 | 124 |
OUTPUT="$1" |
125 |
shift |
|
126 |
fi |
|
127 |
||
9786 | 128 |
[ "$#" -ne 0 ] && { echo "Bad args: $*"; usage; } |
2292 | 129 |
|
130 |
||
131 |
## check ML system |
|
132 |
||
2308 | 133 |
[ -z "$ML_SYSTEM" ] && fail "Missing ML system settings! Unable to run Isabelle." |
2292 | 134 |
|
135 |
||
136 |
## input heap file |
|
137 |
||
3184 | 138 |
[ -z "$INPUT" ] && INPUT="$ISABELLE_LOGIC" |
2292 | 139 |
|
140 |
case "$INPUT" in |
|
2768 | 141 |
RAW_ML_SYSTEM) |
2292 | 142 |
INFILE="" |
143 |
;; |
|
144 |
*/*) |
|
145 |
INFILE="$INPUT" |
|
2343 | 146 |
[ ! -f "$INFILE" ] && fail "Bad heap file: \"$INFILE\"" |
2292 | 147 |
;; |
148 |
*) |
|
9786 | 149 |
INFILE="" |
2308 | 150 |
ISA_PATH="" |
9786 | 151 |
|
152 |
ORIG_IFS="$IFS" |
|
153 |
IFS=":" |
|
154 |
for DIR in $ISABELLE_PATH |
|
2292 | 155 |
do |
9786 | 156 |
DIR="$DIR/$ML_IDENTIFIER" |
157 |
ISA_PATH="$ISA_PATH $DIR\n" |
|
158 |
[ -z "$INFILE" -a -f "$DIR/$INPUT" ] && INFILE="$DIR/$INPUT" |
|
2292 | 159 |
done |
9786 | 160 |
IFS="$ORIG_IFS" |
161 |
||
2308 | 162 |
if [ -z "$INFILE" ]; then |
2343 | 163 |
echo "Unknown logic \"$INPUT\" -- no heap file found in:" >&2 |
9786 | 164 |
echo -ne "$ISA_PATH" >&2 |
2308 | 165 |
exit 2 |
166 |
fi |
|
2292 | 167 |
;; |
168 |
esac |
|
169 |
||
170 |
||
171 |
## output heap file |
|
172 |
||
173 |
case "$OUTPUT" in |
|
174 |
"") |
|
175 |
[ -z "$READONLY" -a -w "$INFILE" ] && OUTFILE="$INFILE" |
|
176 |
;; |
|
177 |
*/*) |
|
178 |
OUTFILE="$OUTPUT" |
|
179 |
;; |
|
180 |
*) |
|
3118 | 181 |
mkdir -p "$ISABELLE_OUTPUT" |
182 |
OUTFILE="$ISABELLE_OUTPUT/$OUTPUT" |
|
2292 | 183 |
;; |
184 |
esac |
|
185 |
||
186 |
||
4333 | 187 |
## prepare tmp directory |
188 |
||
189 |
[ -z "$ISABELLE_TMP_PREFIX" ] && ISABELLE_TMP_PREFIX=/tmp/isabelle |
|
190 |
||
191 |
ISABELLE_TMP="$ISABELLE_TMP_PREFIX$$" |
|
192 |
mkdir -p "$ISABELLE_TMP" |
|
193 |
||
194 |
||
2292 | 195 |
## run it! |
196 |
||
9786 | 197 |
ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-) |
2292 | 198 |
|
2704 | 199 |
[ -n "$MODES" ] && MLTEXT="print_mode := [$MODES]; $MLTEXT" |
200 |
||
9972 | 201 |
if [ -n "$PROOFGENERAL" ]; then |
202 |
MLTEXT="$MLTEXT; ProofGeneral.init $ISAR;" |
|
203 |
elif [ "$ISAR" = true ]; then |
|
204 |
MLTEXT="$MLTEXT; Isar.main();" |
|
205 |
fi |
|
206 |
||
10104 | 207 |
export INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE ISABELLE_TMP |
4333 | 208 |
|
9786 | 209 |
if [ -f "$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM" ]; then |
210 |
"$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM" |
|
4333 | 211 |
else |
9786 | 212 |
"$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE" |
4333 | 213 |
fi |
9786 | 214 |
RC="$?" |
4333 | 215 |
|
216 |
#Do not even think of 'rm -r'!! |
|
9786 | 217 |
rmdir "$ISABELLE_TMP" |
4355 | 218 |
|
9786 | 219 |
exit "$RC" |