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