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