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