lib/scripts/run-smlnj
author wenzelm
Mon, 15 Dec 1997 15:54:47 +0100
changeset 4415 715e5e2064d8
parent 4402 3b53dd8e9e23
child 4505 4a2c872b6513
permissions -rwxr-xr-x
improved COMMIT_RO;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3007
e5efa177ee0c removed -norc;
wenzelm
parents: 2936
diff changeset
     1
#!/bin/bash
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
     2
#
2313
d97eef398257 replaced cat by ucat;
wenzelm
parents: 2302
diff changeset
     3
# $Id$
d97eef398257 replaced cat by ucat;
wenzelm
parents: 2302
diff changeset
     4
#
4402
wenzelm
parents: 4333
diff changeset
     5
# SML/NJ startup script (for 109.27 or later).
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
     6
#
4333
1d326b826851 ISABELLE_TMP;
wenzelm
parents: 3630
diff changeset
     7
# Global vars: INFILE OUTFILE MLTEXT TERMINATE NOWRITE ISABELLE_TMP,
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
     8
# and from settings
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
     9
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    10
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    11
## diagnostics
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    12
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    13
function fail_out()
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    14
{
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    15
  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    16
  exit 2
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    17
}
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    18
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    19
4402
wenzelm
parents: 4333
diff changeset
    20
## basic setup
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    21
4402
wenzelm
parents: 4333
diff changeset
    22
EXIT="fun exit 0 : unit = OS.Process.exit OS.Process.success | exit _ = OS.Process.exit OS.Process.failure;"
wenzelm
parents: 4333
diff changeset
    23
COMMIT="fun commit () = not (SMLofNJ.exportML\"$OUTFILE\");"
4415
715e5e2064d8 improved COMMIT_RO;
wenzelm
parents: 4402
diff changeset
    24
COMMIT_RO='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\\n"); false);'
4402
wenzelm
parents: 4333
diff changeset
    25
eval $($ML_HOME/.arch-n-opsys)
wenzelm
parents: 4333
diff changeset
    26
SUFFIX=".$ARCH-$OPSYS"
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    27
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    28
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    29
## prepare databases
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    30
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    31
DB="$INFILE"
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    32
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    33
if [ -n "$DB" ]; then
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    34
  DB="@SMLload=$INFILE"
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    35
  EXIT=""
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    36
fi
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    37
3051
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    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
721a9e01457b minor tuning;
wenzelm
parents: 2349
diff changeset
    40
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    41
MLTEXT="$EXIT $COMMIT $MLTEXT"
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    42
MLEXIT="commit ();"
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    43
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    44
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    45
## run it!
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    46
2429
747177b67670 fixed ML_HOME;
wenzelm
parents: 2396
diff changeset
    47
START_SML="$ML_HOME/sml $ML_OPTIONS $DB"
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    48
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    49
if [ -n "$TERMINATE" ]; then
3051
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    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
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    54
  RC=$?
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    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
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    57
  RC=$?
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    58
fi
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    59
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    60
#fix heap file name
3051
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    61
[ -n "$OUTFILE" -a -n "$SUFFIX" -a -f "$OUTFILE$SUFFIX" ] \
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    62
  && mv "$OUTFILE$SUFFIX" "$OUTFILE"
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    63
3503
390093b95cb0 NOWRITE;
wenzelm
parents: 3055
diff changeset
    64
[ -n "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
390093b95cb0 NOWRITE;
wenzelm
parents: 3055
diff changeset
    65
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    66
exit $RC