author | wenzelm |
Mon, 15 Dec 1997 15:54:47 +0100 | |
changeset 4415 | 715e5e2064d8 |
parent 4402 | 3b53dd8e9e23 |
child 4505 | 4a2c872b6513 |
permissions | -rwxr-xr-x |
3007 | 1 |
#!/bin/bash |
2302 | 2 |
# |
2313 | 3 |
# $Id$ |
4 |
# |
|
4402 | 5 |
# SML/NJ startup script (for 109.27 or later). |
2302 | 6 |
# |
4333 | 7 |
# Global vars: INFILE OUTFILE MLTEXT TERMINATE NOWRITE ISABELLE_TMP, |
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 |
||
4402 | 20 |
## basic setup |
3046 | 21 |
|
4402 | 22 |
EXIT="fun exit 0 : unit = OS.Process.exit OS.Process.success | exit _ = OS.Process.exit OS.Process.failure;" |
23 |
COMMIT="fun commit () = not (SMLofNJ.exportML\"$OUTFILE\");" |
|
4415 | 24 |
COMMIT_RO='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\\n"); false);' |
4402 | 25 |
eval $($ML_HOME/.arch-n-opsys) |
26 |
SUFFIX=".$ARCH-$OPSYS" |
|
3046 | 27 |
|
28 |
||
29 |
## prepare databases |
|
30 |
||
31 |
DB="$INFILE" |
|
32 |
||
33 |
if [ -n "$DB" ]; then |
|
34 |
DB="@SMLload=$INFILE" |
|
35 |
EXIT="" |
|
2349 | 36 |
fi |
37 |
||
3051 | 38 |
[ -z "$OUTFILE" ] && COMMIT="$COMMIT_RO" |
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2622
diff
changeset
|
39 |
[ -n "$OUTFILE" -a -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } |
2396 | 40 |
|
2349 | 41 |
MLTEXT="$EXIT $COMMIT $MLTEXT" |
3046 | 42 |
MLEXIT="commit ();" |
2302 | 43 |
|
44 |
||
45 |
## run it! |
|
46 |
||
2429 | 47 |
START_SML="$ML_HOME/sml $ML_OPTIONS $DB" |
2302 | 48 |
|
49 |
if [ -n "$TERMINATE" ]; then |
|
3051 | 50 |
sh -c "echo '$MLTEXT' '$MLEXIT' | $START_SML" |
2622
80a81a36dd81
semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents:
2429
diff
changeset
|
51 |
RC=$? |
80a81a36dd81
semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents:
2429
diff
changeset
|
52 |
elif [ -z "$MLTEXT" ]; then |
80a81a36dd81
semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents:
2429
diff
changeset
|
53 |
sh -c "{ $ISABELLE_HOME/lib/scripts/ucat; echo '$MLEXIT'; } | $START_SML" |
2302 | 54 |
RC=$? |
55 |
else |
|
2622
80a81a36dd81
semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents:
2429
diff
changeset
|
56 |
sh -c "{ echo '$MLTEXT'; $ISABELLE_HOME/lib/scripts/ucat; echo '$MLEXIT'; } | $START_SML" |
2302 | 57 |
RC=$? |
58 |
fi |
|
59 |
||
3046 | 60 |
#fix heap file name |
3051 | 61 |
[ -n "$OUTFILE" -a -n "$SUFFIX" -a -f "$OUTFILE$SUFFIX" ] \ |
62 |
&& mv "$OUTFILE$SUFFIX" "$OUTFILE" |
|
3046 | 63 |
|
3503 | 64 |
[ -n "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
65 |
||
2302 | 66 |
exit $RC |