10555
|
1 |
#!/usr/bin/env bash
|
4426
|
2 |
#
|
|
3 |
# $Id$
|
9789
|
4 |
# Author: Markus Wenzel, TU Muenchen
|
|
5 |
# License: GPL (GNU GENERAL PUBLIC LICENSE)
|
4426
|
6 |
#
|
|
7 |
# MLWorks startup script (for 1.0r2 or later).
|
9977
|
8 |
|
10105
|
9 |
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
|
4426
|
10 |
|
|
11 |
|
|
12 |
## diagnostics
|
|
13 |
|
|
14 |
function fail_out()
|
|
15 |
{
|
|
16 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2
|
|
17 |
exit 2
|
|
18 |
}
|
|
19 |
|
|
20 |
|
|
21 |
## prepare databases
|
|
22 |
|
|
23 |
if [ -z "$INFILE" ]; then
|
4505
|
24 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
|
4426
|
25 |
MLWORKS="mlworks-basis -tty"
|
|
26 |
else
|
4505
|
27 |
EXIT=""
|
9868
|
28 |
MLWORKS="mlimage -load $INFILE -tty"
|
4426
|
29 |
fi
|
|
30 |
|
4505
|
31 |
if [ -z "$OUTFILE" ]; then
|
|
32 |
COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);'
|
|
33 |
else
|
|
34 |
COMMIT="fun commit () = (Shell.saveImage (\"$OUTFILE\", false); true);"
|
|
35 |
[ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
|
|
36 |
fi
|
4426
|
37 |
|
|
38 |
|
|
39 |
## run it!
|
|
40 |
|
4505
|
41 |
MLTEXT="$EXIT $COMMIT $MLTEXT"
|
|
42 |
MLEXIT="commit();"
|
4426
|
43 |
|
4505
|
44 |
if [ -z "$TERMINATE" ]; then
|
12111
|
45 |
FEEDER_OPTS=""
|
4426
|
46 |
else
|
4505
|
47 |
FEEDER_OPTS="-q"
|
4426
|
48 |
fi
|
|
49 |
|
9789
|
50 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
|
9868
|
51 |
{ read FPID; "$ML_HOME"/$MLWORKS $ML_OPTIONS 2>&1; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
|
9789
|
52 |
RC="$?"
|
4505
|
53 |
|
|
54 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
|
4426
|
55 |
|
9789
|
56 |
exit "$RC"
|