author | wenzelm |
Sun, 28 Dec 1997 14:58:56 +0100 | |
changeset 4489 | 749600cb5573 |
parent 4333 | 1d326b826851 |
child 4505 | 4a2c872b6513 |
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 |
||
19 |
||
2400 | 20 |
## Poly/ML programs |
2301 | 21 |
|
22 |
POLY=$ML_HOME/poly |
|
23 |
DISCGARB=$ML_HOME/discgarb |
|
24 |
||
25 |
case "$ML_SYSTEM" in |
|
2349 | 26 |
polyml-3.*) |
2314 | 27 |
DISCGARB="$DISCGARB -c" |
2301 | 28 |
;; |
29 |
esac |
|
30 |
||
31 |
||
32 |
## prepare databases |
|
33 |
||
3055 | 34 |
COPYDB=true |
2349 | 35 |
|
2301 | 36 |
if [ -z "$INFILE" ]; then |
2400 | 37 |
INFILE="$ML_HOME/ML_dbase" |
3055 | 38 |
MLTEXT="val use = PolyML.use; val exit = PolyML.exit; $MLTEXT" |
39 |
COPYDB="" |
|
2301 | 40 |
fi |
41 |
||
42 |
if [ -z "$OUTFILE" ]; then |
|
43 |
DB="$INFILE" |
|
2349 | 44 |
ML_OPTIONS="-r $ML_OPTIONS" |
45 |
elif [ "$INFILE" -ef "$OUTFILE" ]; then |
|
2301 | 46 |
DB="$INFILE" |
47 |
elif [ -n "$COPYDB" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
48 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2548 | 49 |
cp "$INFILE" "$OUTFILE" || fail_out |
2349 | 50 |
chmod +w "$OUTFILE" || fail_out |
2301 | 51 |
DB="$OUTFILE" |
52 |
else |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
53 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2349 | 54 |
echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | $POLY -r "$INFILE" |
2301 | 55 |
[ -f "$OUTFILE" ] || fail_out |
56 |
DB="$OUTFILE" |
|
57 |
fi |
|
58 |
||
59 |
||
60 |
## run it! |
|
61 |
||
2349 | 62 |
START_POLY="$POLY $ML_OPTIONS $DB" |
2400 | 63 |
DB_INFO=$(ls -l "$DB") |
2349 | 64 |
|
2301 | 65 |
if [ -n "$TERMINATE" ]; then |
2349 | 66 |
echo "$MLTEXT" | $START_POLY |
2301 | 67 |
RC=$? |
2605 | 68 |
elif [ -z "$MLTEXT" ]; then |
69 |
sh -c "$ISABELLE_HOME/lib/Tools/symbolinput | $START_POLY" |
|
70 |
RC=$? |
|
2301 | 71 |
else |
2605 | 72 |
sh -c "{ echo '$MLTEXT'; $ISABELLE_HOME/lib/Tools/symbolinput; } | $START_POLY" |
2301 | 73 |
RC=$? |
74 |
fi |
|
75 |
||
2400 | 76 |
NEW_DB_INFO=$(ls -l "$DB") |
2605 | 77 |
[ -n "$OUTFILE" -a "$DB_INFO" != "$NEW_DB_INFO" ] && $DISCGARB "$OUTFILE" |
3503 | 78 |
[ -n "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 79 |
|
80 |
exit $RC |