author | wenzelm |
Thu, 28 Sep 2000 14:41:48 +0200 | |
changeset 10105 | f9be78009930 |
parent 9997 | 38598a19e701 |
child 10206 | d48a2e324abf |
permissions | -rwxr-xr-x |
3007 | 1 |
#!/bin/bash |
2301 | 2 |
# |
2314 | 3 |
# $Id$ |
9789 | 4 |
# Author: Markus Wenzel, TU Muenchen |
5 |
# License: GPL (GNU GENERAL PUBLIC LICENSE) |
|
2314 | 6 |
# |
2301 | 7 |
# Poly/ML startup script. |
9977 | 8 |
|
10105 | 9 |
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE |
2301 | 10 |
|
11 |
||
12 |
## diagnostics |
|
13 |
||
2349 | 14 |
function fail_out() |
2301 | 15 |
{ |
2349 | 16 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2 |
2301 | 17 |
exit 2 |
18 |
} |
|
19 |
||
5063 | 20 |
function check_mlhome_file() |
21 |
{ |
|
22 |
if [ ! -f "$1" ]; then |
|
23 |
echo "Unable to locate $1" >&2 |
|
24 |
echo "Please check your ML_HOME setting!" >&2 |
|
25 |
exit 2 |
|
26 |
fi |
|
27 |
} |
|
28 |
||
2301 | 29 |
|
2400 | 30 |
## Poly/ML programs |
2301 | 31 |
|
9789 | 32 |
POLY="$ML_HOME/poly" |
33 |
DISCGARB="$ML_HOME/discgarb" |
|
2301 | 34 |
|
5063 | 35 |
check_mlhome_file "$POLY" |
36 |
check_mlhome_file "$DISCGARB" |
|
37 |
||
2301 | 38 |
|
9765 | 39 |
case "$ML_SYSTEM" in |
40 |
polyml-4.*) |
|
41 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" |
|
42 |
;; |
|
43 |
*) |
|
44 |
EXIT="val exit = PolyML.exit;" |
|
45 |
;; |
|
46 |
esac |
|
47 |
||
48 |
||
2301 | 49 |
## prepare databases |
50 |
||
51 |
if [ -z "$INFILE" ]; then |
|
2400 | 52 |
INFILE="$ML_HOME/ML_dbase" |
5063 | 53 |
check_mlhome_file "$INFILE" |
9765 | 54 |
MLTEXT="val use = PolyML.use; $EXIT $MLTEXT" |
10105 | 55 |
else |
56 |
COPYDB=true |
|
2301 | 57 |
fi |
58 |
||
59 |
if [ -z "$OUTFILE" ]; then |
|
60 |
DB="$INFILE" |
|
2349 | 61 |
ML_OPTIONS="-r $ML_OPTIONS" |
62 |
elif [ "$INFILE" -ef "$OUTFILE" ]; then |
|
2301 | 63 |
DB="$INFILE" |
64 |
elif [ -n "$COPYDB" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
65 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2548 | 66 |
cp "$INFILE" "$OUTFILE" || fail_out |
2349 | 67 |
chmod +w "$OUTFILE" || fail_out |
2301 | 68 |
DB="$OUTFILE" |
69 |
else |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
70 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
9789 | 71 |
echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE" |
2301 | 72 |
[ -f "$OUTFILE" ] || fail_out |
73 |
DB="$OUTFILE" |
|
74 |
fi |
|
75 |
||
76 |
||
77 |
## run it! |
|
78 |
||
4505 | 79 |
if [ -z "$TERMINATE" ]; then |
80 |
FEEDER_OPTS="-s" |
|
81 |
else |
|
82 |
FEEDER_OPTS="-q" |
|
83 |
fi |
|
84 |
||
2400 | 85 |
DB_INFO=$(ls -l "$DB") |
2349 | 86 |
|
9789 | 87 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | \ |
88 |
{ read FPID; "$POLY" $ML_OPTIONS "$DB"; RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
|
89 |
RC="$?" |
|
2301 | 90 |
|
2400 | 91 |
NEW_DB_INFO=$(ls -l "$DB") |
9789 | 92 |
[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && "$DISCGARB" -c "$OUTFILE" |
4505 | 93 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 94 |
|
9789 | 95 |
exit "$RC" |