author | wenzelm |
Fri, 11 Apr 1997 17:30:15 +0200 | |
changeset 2936 | bd33e7aae062 |
parent 2622 | 80a81a36dd81 |
child 3007 | e5efa177ee0c |
permissions | -rwxr-xr-x |
2349 | 1 |
#!/bin/bash -norc |
2302 | 2 |
# |
2313 | 3 |
# $Id$ |
4 |
# |
|
2302 | 5 |
# SML/NJ startup script (for 1.06 or later). |
6 |
# |
|
2349 | 7 |
# Global vars: INFILE OUTFILE COPYDB MLTEXT TERMINATE, |
2302 | 8 |
# and from settings |
9 |
||
10 |
||
11 |
## diagnostics |
|
12 |
||
2349 | 13 |
function fail_out() |
2302 | 14 |
{ |
2349 | 15 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2 |
2302 | 16 |
exit 2 |
17 |
} |
|
18 |
||
19 |
||
20 |
## prepare databases |
|
21 |
||
2349 | 22 |
EXIT="" |
23 |
if [ -z "$INFILE" ]; then |
|
24 |
case "$ML_SYSTEM" in |
|
25 |
smlnj-1.0[678]) |
|
26 |
EXIT="val exit = System.Unix.exit;" |
|
27 |
;; |
|
28 |
smlnj-1.09*) |
|
29 |
EXIT="fun exit 0 = OS.Process.exit OS.Process.success | exit _ = OS.Process.exit OS.Process.failure;" |
|
30 |
;; |
|
31 |
esac |
|
32 |
fi |
|
33 |
||
34 |
DB="$INFILE" |
|
35 |
[ -n "$DB" ] && DB="@SMLload=$INFILE" |
|
36 |
||
37 |
COMMIT="fun commit () = not (exportML\"$OUTFILE\");" |
|
2302 | 38 |
|
39 |
if [ -z "$OUTFILE" ]; then |
|
2349 | 40 |
COMMIT='fun commit () = (output (std_err, "Error - Database is not opened for writing.\n"); false);' |
41 |
elif [ -n "$INFILE" -a ! "$INFILE" -ef "$OUTFILE" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2622
diff
changeset
|
42 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2302 | 43 |
cp "$INFILE" "$OUTFILE" || fail_out |
44 |
fi |
|
45 |
||
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2622
diff
changeset
|
46 |
[ -n "$OUTFILE" -a -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } |
2396 | 47 |
|
2349 | 48 |
MLTEXT="$EXIT $COMMIT $MLTEXT" |
49 |
MLEXIT="commit();" |
|
2302 | 50 |
|
51 |
||
52 |
## run it! |
|
53 |
||
2429 | 54 |
START_SML="$ML_HOME/sml $ML_OPTIONS $DB" |
2302 | 55 |
|
56 |
if [ -n "$TERMINATE" ]; then |
|
2622
80a81a36dd81
semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents:
2429
diff
changeset
|
57 |
{ echo "$MLTEXT" "$MLEXIT" } | $START_SML |
80a81a36dd81
semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents:
2429
diff
changeset
|
58 |
RC=$? |
80a81a36dd81
semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents:
2429
diff
changeset
|
59 |
elif [ -z "$MLTEXT" ]; then |
80a81a36dd81
semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents:
2429
diff
changeset
|
60 |
sh -c "{ $ISABELLE_HOME/lib/scripts/ucat; echo '$MLEXIT'; } | $START_SML" |
2302 | 61 |
RC=$? |
62 |
else |
|
2622
80a81a36dd81
semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents:
2429
diff
changeset
|
63 |
sh -c "{ echo '$MLTEXT'; $ISABELLE_HOME/lib/scripts/ucat; echo '$MLEXIT'; } | $START_SML" |
2302 | 64 |
RC=$? |
65 |
fi |
|
66 |
||
67 |
exit $RC |