author | wenzelm |
Fri, 11 Apr 1997 17:30:15 +0200 | |
changeset 2936 | bd33e7aae062 |
parent 2605 | 1effe7413486 |
child 3007 | e5efa177ee0c |
permissions | -rwxr-xr-x |
2349 | 1 |
#!/bin/bash -norc |
2301 | 2 |
# |
2314 | 3 |
# $Id$ |
4 |
# |
|
2301 | 5 |
# Poly/ML startup script. |
6 |
# |
|
2349 | 7 |
# Global vars: INFILE OUTFILE COPYDB MLTEXT TERMINATE, |
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 |
||
2349 | 34 |
MLINIT="" |
35 |
||
2301 | 36 |
if [ -z "$INFILE" ]; then |
2400 | 37 |
INFILE="$ML_HOME/ML_dbase" |
2349 | 38 |
MLINIT="val use = PolyML.use; val exit = PolyML.exit; fun init_database () = ();" |
2301 | 39 |
fi |
40 |
||
41 |
if [ -z "$OUTFILE" ]; then |
|
42 |
DB="$INFILE" |
|
2349 | 43 |
ML_OPTIONS="-r $ML_OPTIONS" |
44 |
elif [ "$INFILE" -ef "$OUTFILE" ]; then |
|
2301 | 45 |
DB="$INFILE" |
46 |
elif [ -n "$COPYDB" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
47 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2548 | 48 |
cp "$INFILE" "$OUTFILE" || fail_out |
2349 | 49 |
chmod +w "$OUTFILE" || fail_out |
2301 | 50 |
DB="$OUTFILE" |
51 |
else |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
52 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2349 | 53 |
echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | $POLY -r "$INFILE" |
2301 | 54 |
[ -f "$OUTFILE" ] || fail_out |
55 |
DB="$OUTFILE" |
|
2349 | 56 |
MLINIT="$MLINIT init_database ();" |
2301 | 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 |
|
65 |
[ -n "$MLINIT" ] && MLTEXT="$MLINIT $MLTEXT" |
|
2301 | 66 |
|
67 |
if [ -n "$TERMINATE" ]; then |
|
2349 | 68 |
echo "$MLTEXT" | $START_POLY |
2301 | 69 |
RC=$? |
2605 | 70 |
elif [ -z "$MLTEXT" ]; then |
71 |
sh -c "$ISABELLE_HOME/lib/Tools/symbolinput | $START_POLY" |
|
72 |
RC=$? |
|
2301 | 73 |
else |
2605 | 74 |
sh -c "{ echo '$MLTEXT'; $ISABELLE_HOME/lib/Tools/symbolinput; } | $START_POLY" |
2301 | 75 |
RC=$? |
76 |
fi |
|
77 |
||
2400 | 78 |
NEW_DB_INFO=$(ls -l "$DB") |
2605 | 79 |
[ -n "$OUTFILE" -a "$DB_INFO" != "$NEW_DB_INFO" ] && $DISCGARB "$OUTFILE" |
2301 | 80 |
|
81 |
exit $RC |