lib/scripts/run-smlnj
author paulson
Mon, 17 Jan 2000 14:10:32 +0100
changeset 8129 29e239c7b8c2
parent 6078 e01e2328d0f0
child 9789 7e5e6c47c0b5
permissions -rwxr-xr-x
Thm.instantiate no longer normalizes, but Drule.instantiate does
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
#
5708
fb09ab6a447f dropped support for SML/NJ 109.x;
wenzelm
parents: 5063
diff changeset
     5
# SML/NJ startup script (for 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
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    19
function check_mlhome_file()
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    20
{
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    21
  if [ ! -f "$1" ]; then
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    22
    echo "Unable to locate $1" >&2
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    23
    echo "Please check your ML_HOME setting!" >&2
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    24
    exit 2
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    25
  fi
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    26
}
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    27
6078
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    28
function check_heap_file()
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    29
{
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    30
  if [ ! -f "$1" ]; then
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    31
    echo "Expected to find ML heap file $1" >&2
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    32
    return 1
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    33
  else
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    34
    return 0
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    35
  fi
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    36
}
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    37
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    38
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    39
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    40
## compiler binaries
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    41
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    42
SML="$ML_HOME/sml"
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    43
ARCH_N_OPSYS="$ML_HOME/.arch-n-opsys"
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    44
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    45
check_mlhome_file "$SML"
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    46
check_mlhome_file "$ARCH_N_OPSYS"
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    47
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    48
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    49
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    50
## prepare databases
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    51
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    52
if [ -z "$INFILE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    53
  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
    54
  DB=""
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    55
else
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    56
  EXIT=""
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    57
  DB="@SMLload=$INFILE"
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    58
fi
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    59
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    60
if [ -z "$OUTFILE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    61
  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
    62
else
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    63
  COMMIT="fun commit () = not (SMLofNJ.exportML\"$OUTFILE\");"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    64
  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    65
fi
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    66
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    67
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    68
## run it!
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    69
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    70
MLTEXT="$EXIT $COMMIT $MLTEXT"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    71
MLEXIT="commit();"
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    72
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    73
if [ -z "$TERMINATE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    74
  FEEDER_OPTS=""
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    75
else
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    76
  FEEDER_OPTS="-q"
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    77
fi
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    78
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    79
$ISABELLE_HOME/lib/scripts/feeder -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    80
  { read FPID; $SML $ML_OPTIONS $DB; RC=$?; kill -HUP $FPID; exit $RC; }
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    81
RC=$?
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    82
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    83
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    84
## fix heap file name and permissions
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    85
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    86
if [ -n "$OUTFILE" ]; then
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    87
  eval $($ARCH_N_OPSYS)
6078
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    88
  [ -z "$HEAP_SUFFIX" ] && HEAP_SUFFIX="$ARCH-$OPSYS"
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    89
  HEAP="$OUTFILE.$HEAP_SUFFIX"
e01e2328d0f0 more robust heap file detection;
wenzelm
parents: 5708
diff changeset
    90
  check_heap_file "$HEAP" && mv "$HEAP" "$OUTFILE" && \
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    91
    [ -n "$NOWRITE" ] && chmod -w "$OUTFILE"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    92
fi
3503
390093b95cb0 NOWRITE;
wenzelm
parents: 3055
diff changeset
    93
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    94
exit $RC