lib/scripts/run-smlnj
author paulson
Thu, 05 Jun 1997 13:22:25 +0200
changeset 3403 6cc663f6d62e
parent 3055 5da4afa207ad
child 3503 390093b95cb0
permissions -rwxr-xr-x
A slight simplification of optstring The new "simpset" keyword in the "recdef" declaration
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
#
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
     5
# SML/NJ startup script (for 1.06 or later).
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
     6
#
3055
5da4afa207ad removed COPYDB flag;
wenzelm
parents: 3051
diff changeset
     7
# Global vars: INFILE OUTFILE MLTEXT TERMINATE,
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
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    20
## version specific stuff
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    21
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    22
EXIT=""
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    23
COMMIT=""
3051
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    24
SUFFIX=""
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    25
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    26
case "$ML_SYSTEM" in
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    27
  smlnj-1.0[678]*)
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    28
    EXIT="val exit = System.Unix.exit;"
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    29
    COMMIT="fun commit () = not (exportML\"$OUTFILE\");"
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    30
    COMMIT_RO='fun commit () = (output (std_err, "Error - Database is not opened for writing.\\n"); false);'
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    31
    ;;
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    32
  smlnj-1.09*)
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    33
    EXIT="fun exit 0 : unit = OS.Process.exit OS.Process.success | exit _ = OS.Process.exit OS.Process.failure;"
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    34
    COMMIT="fun commit () = not (SMLofNJ.exportML\"$OUTFILE\");"
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    35
    COMMIT_RO='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\\n"); false);'
3051
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    36
    eval $($ML_HOME/.arch-n-opsys)
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    37
    SUFFIX=".$ARCH-$OPSYS"
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    38
    ;;
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    39
esac
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    40
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    41
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    42
## prepare databases
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    43
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    44
DB="$INFILE"
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    45
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    46
if [ -n "$DB" ]; then
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    47
  DB="@SMLload=$INFILE"
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    48
  EXIT=""
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    49
fi
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    50
3051
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    51
[ -z "$OUTFILE" ] && COMMIT="$COMMIT_RO"
2936
bd33e7aae062 fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents: 2622
diff changeset
    52
[ -n "$OUTFILE" -a -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
2396
721a9e01457b minor tuning;
wenzelm
parents: 2349
diff changeset
    53
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    54
MLTEXT="$EXIT $COMMIT $MLTEXT"
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    55
MLEXIT="commit ();"
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    56
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    57
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    58
## run it!
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    59
2429
747177b67670 fixed ML_HOME;
wenzelm
parents: 2396
diff changeset
    60
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
    61
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    62
if [ -n "$TERMINATE" ]; then
3051
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    63
  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
    64
  RC=$?
80a81a36dd81 semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents: 2429
diff changeset
    65
elif [ -z "$MLTEXT" ]; then
80a81a36dd81 semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents: 2429
diff changeset
    66
  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
    67
  RC=$?
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    68
else
2622
80a81a36dd81 semi fix of piping-quit peoblem (should work on systems with *real* sh);
wenzelm
parents: 2429
diff changeset
    69
  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
    70
  RC=$?
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    71
fi
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    72
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    73
#fix heap file name
3051
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    74
[ -n "$OUTFILE" -a -n "$SUFFIX" -a -f "$OUTFILE$SUFFIX" ] \
30490aa41356 misc tuning;
wenzelm
parents: 3046
diff changeset
    75
  && mv "$OUTFILE$SUFFIX" "$OUTFILE"
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    76
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    77
exit $RC