author | wenzelm |
Mon, 08 May 2000 10:49:27 +0200 | |
changeset 8821 | b5c3aec69462 |
parent 8360 | 885a6414b9c8 |
child 9765 | 46def28153d6 |
permissions | -rwxr-xr-x |
3007 | 1 |
#!/bin/bash |
2301 | 2 |
# |
2314 | 3 |
# $Id$ |
4 |
# |
|
2301 | 5 |
# Poly/ML startup script. |
6 |
# |
|
8360 | 7 |
# Global vars: INFILE OUTFILE COMPRESS 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 |
|
38 |
## prepare databases |
|
39 |
||
3055 | 40 |
COPYDB=true |
2349 | 41 |
|
2301 | 42 |
if [ -z "$INFILE" ]; then |
2400 | 43 |
INFILE="$ML_HOME/ML_dbase" |
5063 | 44 |
check_mlhome_file "$INFILE" |
3055 | 45 |
MLTEXT="val use = PolyML.use; val exit = PolyML.exit; $MLTEXT" |
46 |
COPYDB="" |
|
2301 | 47 |
fi |
48 |
||
49 |
if [ -z "$OUTFILE" ]; then |
|
50 |
DB="$INFILE" |
|
2349 | 51 |
ML_OPTIONS="-r $ML_OPTIONS" |
52 |
elif [ "$INFILE" -ef "$OUTFILE" ]; then |
|
2301 | 53 |
DB="$INFILE" |
54 |
elif [ -n "$COPYDB" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
55 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2548 | 56 |
cp "$INFILE" "$OUTFILE" || fail_out |
2349 | 57 |
chmod +w "$OUTFILE" || fail_out |
2301 | 58 |
DB="$OUTFILE" |
59 |
else |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
60 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2349 | 61 |
echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | $POLY -r "$INFILE" |
2301 | 62 |
[ -f "$OUTFILE" ] || fail_out |
63 |
DB="$OUTFILE" |
|
64 |
fi |
|
65 |
||
66 |
||
67 |
## run it! |
|
68 |
||
4505 | 69 |
if [ -z "$TERMINATE" ]; then |
70 |
FEEDER_OPTS="-s" |
|
71 |
else |
|
72 |
FEEDER_OPTS="-q" |
|
73 |
fi |
|
74 |
||
2400 | 75 |
DB_INFO=$(ls -l "$DB") |
2349 | 76 |
|
4505 | 77 |
$ISABELLE_HOME/lib/scripts/feeder -p -h "$MLTEXT" $FEEDER_OPTS | \ |
78 |
{ read FPID; $POLY $ML_OPTIONS "$DB"; RC=$?; kill -HUP $FPID; exit $RC; } |
|
79 |
RC=$? |
|
2301 | 80 |
|
2400 | 81 |
NEW_DB_INFO=$(ls -l "$DB") |
8821 | 82 |
[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && $DISCGARB -c "$OUTFILE" |
4505 | 83 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 84 |
|
85 |
exit $RC |