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