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