author | nipkow |
Tue, 28 Sep 1999 16:36:12 +0200 | |
changeset 7626 | 5997f35954d7 |
parent 5063 | d45ec8d00ab0 |
child 9789 | 7e5e6c47c0b5 |
permissions | -rwxr-xr-x |
3007 | 1 |
#!/bin/bash |
2411 | 2 |
# |
3 |
# $Id$ |
|
4 |
# |
|
5 |
# SML/NJ startup script (for 0.93). |
|
6 |
# |
|
4333 | 7 |
# Global vars: INFILE OUTFILE MLTEXT TERMINATE NOWRITE ISABELLE_TMP, |
2411 | 8 |
# and from settings |
9 |
||
10 |
||
11 |
## diagnostics |
|
12 |
||
13 |
function fail_out() |
|
14 |
{ |
|
15 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2 |
|
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 |
||
2411 | 28 |
|
29 |
## prepare databases |
|
30 |
||
2440 | 31 |
if [ -z "$INFILE" ]; then |
32 |
INFILE="$ML_HOME/sml" |
|
5063 | 33 |
check_mlhome_file "$INFILE" |
4513 | 34 |
EXIT="val exit: int -> unit = System.Unsafe.CInterface.exit;" |
2440 | 35 |
else |
36 |
EXIT="" |
|
37 |
fi |
|
2411 | 38 |
|
39 |
MOVE="" |
|
40 |
||
41 |
if [ -z "$OUTFILE" ]; then |
|
4513 | 42 |
COMMIT='fun commit () = (output (std_err, "Error - Database is not opened for writing.\n"); false);' |
2411 | 43 |
else |
44 |
if [ "$INFILE" -ef "$OUTFILE" ]; then |
|
45 |
OUTDIR=$(dirname "$OUTFILE")/tmp |
|
46 |
OUTFILE=$OUTDIR/$(basename "$OUTFILE") |
|
47 |
mkdir -p "$OUTDIR" || fail_out |
|
48 |
MOVE=true |
|
49 |
fi |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2622
diff
changeset
|
50 |
[ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } |
2411 | 51 |
COMMIT="fun commit () = not (exportML\"$OUTFILE\");" |
52 |
fi |
|
53 |
||
54 |
||
55 |
## run it! |
|
56 |
||
4513 | 57 |
MLTEXT="$EXIT $COMMIT $MLTEXT" |
58 |
MLEXIT="commit();" |
|
2411 | 59 |
|
4513 | 60 |
if [ -z "$TERMINATE" ]; then |
61 |
FEEDER_OPTS="" |
|
2411 | 62 |
else |
4513 | 63 |
FEEDER_OPTS="-q" |
2411 | 64 |
fi |
65 |
||
4513 | 66 |
$ISABELLE_HOME/lib/scripts/feeder -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \ |
67 |
{ read FPID; $INFILE $ML_OPTIONS; RC=$?; kill -HUP $FPID; exit $RC; } |
|
68 |
RC=$? |
|
69 |
||
70 |
||
71 |
## fix heap file |
|
72 |
||
73 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
|
3503 | 74 |
|
2411 | 75 |
if [ -n "$MOVE" -a -f "$OUTFILE" ]; then |
2551 | 76 |
rm -f "$INFILE" || fail_out |
77 |
mv "$OUTFILE" "$INFILE" || fail_out |
|
2411 | 78 |
fi |
79 |
||
80 |
exit $RC |