author | wenzelm |
Sat, 04 Sep 1999 21:05:01 +0200 | |
changeset 7474 | 43cedde6d52a |
parent 5063 | d45ec8d00ab0 |
child 8360 | 885a6414b9c8 |
permissions | -rwxr-xr-x |
3007 | 1 |
#!/bin/bash |
2301 | 2 |
# |
2314 | 3 |
# $Id$ |
4 |
# |
|
2301 | 5 |
# Poly/ML startup script. |
6 |
# |
|
4333 | 7 |
# Global vars: INFILE OUTFILE MLTEXT TERMINATE NOWRITE ISABELLE_TMP, |
2301 | 8 |
# and from settings |
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 |
||
5063 | 19 |
function check_mlhome_file() |
20 |
{ |
|
21 |
if [ ! -f "$1" ]; then |
|
22 |
echo "Unable to locate $1" >&2 |
|
23 |
echo "Please check your ML_HOME setting!" >&2 |
|
24 |
exit 2 |
|
25 |
fi |
|
26 |
} |
|
27 |
||
2301 | 28 |
|
2400 | 29 |
## Poly/ML programs |
2301 | 30 |
|
31 |
POLY=$ML_HOME/poly |
|
32 |
DISCGARB=$ML_HOME/discgarb |
|
33 |
||
5063 | 34 |
check_mlhome_file "$POLY" |
35 |
check_mlhome_file "$DISCGARB" |
|
36 |
||
2301 | 37 |
case "$ML_SYSTEM" in |
2349 | 38 |
polyml-3.*) |
2314 | 39 |
DISCGARB="$DISCGARB -c" |
2301 | 40 |
;; |
41 |
esac |
|
42 |
||
43 |
||
44 |
## prepare databases |
|
45 |
||
3055 | 46 |
COPYDB=true |
2349 | 47 |
|
2301 | 48 |
if [ -z "$INFILE" ]; then |
2400 | 49 |
INFILE="$ML_HOME/ML_dbase" |
5063 | 50 |
check_mlhome_file "$INFILE" |
3055 | 51 |
MLTEXT="val use = PolyML.use; val exit = PolyML.exit; $MLTEXT" |
52 |
COPYDB="" |
|
2301 | 53 |
fi |
54 |
||
55 |
if [ -z "$OUTFILE" ]; then |
|
56 |
DB="$INFILE" |
|
2349 | 57 |
ML_OPTIONS="-r $ML_OPTIONS" |
58 |
elif [ "$INFILE" -ef "$OUTFILE" ]; then |
|
2301 | 59 |
DB="$INFILE" |
60 |
elif [ -n "$COPYDB" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
61 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2548 | 62 |
cp "$INFILE" "$OUTFILE" || fail_out |
2349 | 63 |
chmod +w "$OUTFILE" || fail_out |
2301 | 64 |
DB="$OUTFILE" |
65 |
else |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
66 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2349 | 67 |
echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | $POLY -r "$INFILE" |
2301 | 68 |
[ -f "$OUTFILE" ] || fail_out |
69 |
DB="$OUTFILE" |
|
70 |
fi |
|
71 |
||
72 |
||
73 |
## run it! |
|
74 |
||
4505 | 75 |
if [ -z "$TERMINATE" ]; then |
76 |
FEEDER_OPTS="-s" |
|
77 |
else |
|
78 |
FEEDER_OPTS="-q" |
|
79 |
fi |
|
80 |
||
2400 | 81 |
DB_INFO=$(ls -l "$DB") |
2349 | 82 |
|
4505 | 83 |
$ISABELLE_HOME/lib/scripts/feeder -p -h "$MLTEXT" $FEEDER_OPTS | \ |
84 |
{ read FPID; $POLY $ML_OPTIONS "$DB"; RC=$?; kill -HUP $FPID; exit $RC; } |
|
85 |
RC=$? |
|
2301 | 86 |
|
2400 | 87 |
NEW_DB_INFO=$(ls -l "$DB") |
2605 | 88 |
[ -n "$OUTFILE" -a "$DB_INFO" != "$NEW_DB_INFO" ] && $DISCGARB "$OUTFILE" |
4505 | 89 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 90 |
|
91 |
exit $RC |