lib/scripts/run-smlnj
author wenzelm
Fri, 13 Mar 1998 18:15:14 +0100
changeset 4744 4469d498cd48
parent 4505 4a2c872b6513
child 5063 d45ec8d00ab0
permissions -rwxr-xr-x
moved addsplits [expand_if] from HOL_basic_ss to HOL_ss;
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
#
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
     5
# SML/NJ startup script (for 109.27-109.33, 110 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
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    20
## prepare databases
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    21
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    22
if [ -z "$INFILE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    23
  EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    24
  DB=""
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    25
else
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    26
  EXIT=""
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    27
  DB="@SMLload=$INFILE"
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    28
fi
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    29
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    30
if [ -z "$OUTFILE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    31
  COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);'
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    32
else
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    33
  COMMIT="fun commit () = not (SMLofNJ.exportML\"$OUTFILE\");"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    34
  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    35
fi
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    36
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    37
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    38
## run it!
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    39
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    40
MLTEXT="$EXIT $COMMIT $MLTEXT"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    41
MLEXIT="commit();"
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    42
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    43
if [ -z "$TERMINATE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    44
  FEEDER_OPTS=""
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    45
else
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    46
  FEEDER_OPTS="-q"
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    47
fi
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    48
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    49
$ISABELLE_HOME/lib/scripts/feeder -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    50
  { read FPID; $ML_HOME/sml $ML_OPTIONS $DB; RC=$?; kill -HUP $FPID; exit $RC; }
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    51
RC=$?
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    52
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    53
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    54
## fix heap file name and permissions
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    55
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    56
if [ -n "$OUTFILE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    57
  eval $($ML_HOME/.arch-n-opsys)
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    58
  SUFFIX=".$ARCH-$OPSYS"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    59
  if [ -f "$OUTFILE$SUFFIX" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    60
    mv "$OUTFILE$SUFFIX" "$OUTFILE"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    61
    [ -n "$NOWRITE" ] && chmod -w "$OUTFILE"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    62
  fi
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    63
fi
3503
390093b95cb0 NOWRITE;
wenzelm
parents: 3055
diff changeset
    64
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    65
exit $RC