author | wenzelm |
Fri, 25 Apr 1997 15:08:52 +0200 | |
changeset 3054 | c16029f41ad9 |
parent 3007 | e5efa177ee0c |
child 3118 | 24dae6222579 |
permissions | -rwxr-xr-x |
3007 | 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" |
|
2343 | 29 |
echo " -u pass 'exit_use_dir\".\";' to the ML session" |
2292 | 30 |
echo |
31 |
echo " INPUT (default \"$DEFAULT_LOGIC\") and OUTPUT specify in/out heaps." |
|
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="" |
|
54 |
||
3054 | 55 |
while getopts "e:m:qru" OPT |
2292 | 56 |
do |
57 |
case "$OPT" in |
|
58 |
e) |
|
59 |
MLTEXT="$MLTEXT $OPTARG" |
|
60 |
;; |
|
2704 | 61 |
m) |
62 |
if [ -z "$MODES" ]; then |
|
63 |
MODES="\"$OPTARG\"" |
|
64 |
else |
|
2711 | 65 |
MODES="\"$OPTARG\", $MODES" |
2704 | 66 |
fi |
67 |
;; |
|
2292 | 68 |
q) |
69 |
TERMINATE=true |
|
70 |
;; |
|
71 |
r) |
|
72 |
READONLY=true |
|
73 |
;; |
|
74 |
u) |
|
2343 | 75 |
MLTEXT="$MLTEXT exit_use_dir\".\";" |
2292 | 76 |
;; |
77 |
\?) |
|
78 |
usage |
|
79 |
;; |
|
80 |
esac |
|
81 |
done |
|
82 |
||
83 |
shift $(($OPTIND - 1)) |
|
84 |
||
85 |
||
86 |
# args |
|
87 |
||
88 |
INPUT="" |
|
89 |
OUTPUT="" |
|
90 |
||
91 |
if [ $# -ge 1 ]; then |
|
92 |
INPUT="$1" |
|
93 |
shift |
|
94 |
fi |
|
95 |
||
96 |
if [ $# -ge 1 ]; then |
|
97 |
OUTPUT="$1" |
|
98 |
shift |
|
99 |
fi |
|
100 |
||
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2768
diff
changeset
|
101 |
[ $# -ne 0 ] && { echo "Bad args: $*"; usage; } |
2292 | 102 |
|
103 |
||
104 |
## check ML system |
|
105 |
||
2308 | 106 |
[ -z "$ML_SYSTEM" ] && fail "Missing ML system settings! Unable to run Isabelle." |
2292 | 107 |
|
108 |
||
109 |
## input heap file |
|
110 |
||
111 |
[ -z "$INPUT" ] && INPUT="$DEFAULT_LOGIC" |
|
112 |
||
113 |
case "$INPUT" in |
|
2768 | 114 |
RAW_ML_SYSTEM) |
2292 | 115 |
INFILE="" |
116 |
;; |
|
117 |
*/*) |
|
118 |
INFILE="$INPUT" |
|
2343 | 119 |
[ ! -f "$INFILE" ] && fail "Bad heap file: \"$INFILE\"" |
2292 | 120 |
;; |
121 |
*) |
|
2308 | 122 |
ISA_PATH="" |
2292 | 123 |
INFILE="" |
124 |
for DIR in $(echo $ISABELLE_PATH | tr : " ") |
|
125 |
do |
|
2968 | 126 |
ISA_PATH="$ISA_PATH $DIR" |
127 |
[ -z "$INFILE" -a -f $DIR/$INPUT ] && INFILE=$DIR/$INPUT |
|
2292 | 128 |
done |
2308 | 129 |
if [ -z "$INFILE" ]; then |
2343 | 130 |
echo "Unknown logic \"$INPUT\" -- no heap file found in:" >&2 |
2308 | 131 |
for DIR in $ISA_PATH |
132 |
do |
|
2343 | 133 |
echo " $DIR" >&2 |
2308 | 134 |
done |
135 |
exit 2 |
|
136 |
fi |
|
2292 | 137 |
;; |
138 |
esac |
|
139 |
||
140 |
||
141 |
## output heap file |
|
142 |
||
143 |
case "$OUTPUT" in |
|
144 |
"") |
|
145 |
[ -z "$READONLY" -a -w "$INFILE" ] && OUTFILE="$INFILE" |
|
146 |
;; |
|
147 |
*/*) |
|
148 |
OUTFILE="$OUTPUT" |
|
149 |
;; |
|
150 |
*) |
|
2968 | 151 |
mkdir -p "$ISABELLE_OUTPUT_DIR" |
152 |
OUTFILE="$ISABELLE_OUTPUT_DIR/$OUTPUT" |
|
2292 | 153 |
;; |
154 |
esac |
|
155 |
||
156 |
||
157 |
## run it! |
|
158 |
||
159 |
ML_SYSTEM_BASE=$(echo $ML_SYSTEM | cut -f1 -d-) |
|
160 |
||
2704 | 161 |
[ -n "$MODES" ] && MLTEXT="print_mode := [$MODES]; $MLTEXT" |
162 |
||
3054 | 163 |
export INFILE OUTFILE MLTEXT TERMINATE |
2292 | 164 |
[ -f $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM ] && exec $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM |
165 |
exec $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE |