author | wenzelm |
Sun, 05 Jun 2005 21:32:37 +0200 | |
changeset 16285 | 75954ae8b247 |
parent 16254 | 1b2683e18fd2 |
child 16374 | f4b7cf8975af |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2301 | 2 |
# |
2314 | 3 |
# $Id$ |
9789 | 4 |
# Author: Markus Wenzel, TU Muenchen |
2314 | 5 |
# |
2301 | 6 |
# Poly/ML startup script. |
9977 | 7 |
|
10105 | 8 |
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE |
2301 | 9 |
|
10 |
||
11 |
## diagnostics |
|
12 |
||
2349 | 13 |
function fail_out() |
2301 | 14 |
{ |
2349 | 15 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2 |
2301 | 16 |
exit 2 |
17 |
} |
|
18 |
||
10206 | 19 |
function check_file() |
5063 | 20 |
{ |
21 |
if [ ! -f "$1" ]; then |
|
22 |
echo "Unable to locate $1" >&2 |
|
10206 | 23 |
echo "Please check your ML system settings!" >&2 |
5063 | 24 |
exit 2 |
25 |
fi |
|
26 |
} |
|
27 |
||
2301 | 28 |
|
2400 | 29 |
## Poly/ML programs |
2301 | 30 |
|
10206 | 31 |
ML_DBASE_PREFIX="" |
9789 | 32 |
POLY="$ML_HOME/poly" |
10206 | 33 |
check_file "$POLY" |
2301 | 34 |
|
9765 | 35 |
case "$ML_SYSTEM" in |
36 |
polyml-4.*) |
|
10206 | 37 |
if [ -z "$ML_DBASE" ]; then |
38 |
if [ -z "$COPYDB" ]; then |
|
39 |
ML_DBASE_PREFIX="$ML_HOME/" |
|
40 |
ML_DBASE="ML_dbase" |
|
41 |
else |
|
42 |
ML_DBASE="$ML_HOME/ML_dbase" |
|
43 |
fi |
|
44 |
POLYPATH="$ML_HOME" |
|
45 |
else |
|
46 |
POLYPATH=$(dirname "$ML_DBASE") |
|
47 |
fi |
|
48 |
export POLYPATH |
|
49 |
||
50 |
DISCGARB="$POLY" |
|
51 |
DISCGARB_OPTIONS="-d -c" |
|
52 |
||
9765 | 53 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" |
54 |
;; |
|
55 |
*) |
|
10206 | 56 |
if [ -z "$ML_DBASE" ]; then |
57 |
ML_DBASE="$ML_HOME/ML_dbase" |
|
58 |
fi |
|
59 |
||
60 |
DISCGARB="$ML_HOME/discgarb" |
|
61 |
DISCGARB_OPTIONS="-c" |
|
62 |
check_file "$DISCGARB" |
|
63 |
||
9765 | 64 |
EXIT="val exit = PolyML.exit;" |
65 |
;; |
|
66 |
esac |
|
67 |
||
68 |
||
2301 | 69 |
## prepare databases |
70 |
||
71 |
if [ -z "$INFILE" ]; then |
|
10206 | 72 |
check_file "$ML_DBASE_PREFIX$ML_DBASE" |
73 |
INFILE="$ML_DBASE" |
|
9765 | 74 |
MLTEXT="val use = PolyML.use; $EXIT $MLTEXT" |
16285 | 75 |
case "$ML_SYSTEM" in |
76 |
polyml-4.1.[12]) |
|
77 |
DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S 180" |
|
78 |
;; |
|
79 |
polyml-4.1.*) |
|
80 |
DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S max" |
|
81 |
;; |
|
82 |
esac |
|
10105 | 83 |
else |
84 |
COPYDB=true |
|
2301 | 85 |
fi |
86 |
||
87 |
if [ -z "$OUTFILE" ]; then |
|
88 |
DB="$INFILE" |
|
15850
30e878979457
no longer need feeder to run normal interactive sessions;
wenzelm
parents:
14981
diff
changeset
|
89 |
ML_OPTIONS="-r $ML_OPTIONS" |
2349 | 90 |
elif [ "$INFILE" -ef "$OUTFILE" ]; then |
2301 | 91 |
DB="$INFILE" |
92 |
elif [ -n "$COPYDB" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
93 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2548 | 94 |
cp "$INFILE" "$OUTFILE" || fail_out |
2349 | 95 |
chmod +w "$OUTFILE" || fail_out |
2301 | 96 |
DB="$OUTFILE" |
97 |
else |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
98 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
9789 | 99 |
echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE" |
2301 | 100 |
[ -f "$OUTFILE" ] || fail_out |
101 |
DB="$OUTFILE" |
|
102 |
fi |
|
103 |
||
104 |
||
105 |
## run it! |
|
106 |
||
16254
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
107 |
if [ -z "$TERMINATE" ]; then |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
108 |
FEEDER_OPTS="" |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
109 |
else |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
110 |
FEEDER_OPTS="-q" |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
111 |
fi |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
112 |
|
15850
30e878979457
no longer need feeder to run normal interactive sessions;
wenzelm
parents:
14981
diff
changeset
|
113 |
DB_INFO=$(ls -l "$DB" 2>/dev/null) |
30e878979457
no longer need feeder to run normal interactive sessions;
wenzelm
parents:
14981
diff
changeset
|
114 |
|
16254
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
115 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | \ |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
116 |
{ read FPID; "$POLY" $ML_OPTIONS "$DB"; RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
9789 | 117 |
RC="$?" |
2301 | 118 |
|
10206 | 119 |
NEW_DB_INFO=$(ls -l "$DB" 2>/dev/null) |
120 |
[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && \ |
|
121 |
"$DISCGARB" $DISCGARB_OPTIONS "$OUTFILE" |
|
4505 | 122 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 123 |
|
9789 | 124 |
exit "$RC" |