lib/scripts/run-smlnj
author paulson
Mon, 16 Nov 1998 10:36:30 +0100
changeset 5865 2303f5a3036d
parent 5708 fb09ab6a447f
child 6078 e01e2328d0f0
permissions -rwxr-xr-x
moved some facts about Pi from ex/PiSets to Fun.ML
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
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    28
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    29
## compiler binaries
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    30
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    31
SML="$ML_HOME/sml"
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    32
ARCH_N_OPSYS="$ML_HOME/.arch-n-opsys"
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    33
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    34
check_mlhome_file "$SML"
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    35
check_mlhome_file "$ARCH_N_OPSYS"
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    36
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    37
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    38
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    39
## prepare databases
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    40
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    41
if [ -z "$INFILE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    42
  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
    43
  DB=""
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    44
else
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    45
  EXIT=""
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    46
  DB="@SMLload=$INFILE"
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    47
fi
e9475a7be4ad various fixes;
wenzelm
parents: 2316
diff changeset
    48
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    49
if [ -z "$OUTFILE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    50
  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
    51
else
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    52
  COMMIT="fun commit () = not (SMLofNJ.exportML\"$OUTFILE\");"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    53
  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    54
fi
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    55
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
## run it!
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    58
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    59
MLTEXT="$EXIT $COMMIT $MLTEXT"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    60
MLEXIT="commit();"
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    61
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    62
if [ -z "$TERMINATE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    63
  FEEDER_OPTS=""
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    64
else
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    65
  FEEDER_OPTS="-q"
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    66
fi
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    67
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    68
$ISABELLE_HOME/lib/scripts/feeder -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    69
  { 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
    70
RC=$?
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    71
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    72
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    73
## fix heap file name and permissions
3046
6b7935317538 adapted to SML/NJ 1.09.27;
wenzelm
parents: 3010
diff changeset
    74
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    75
if [ -n "$OUTFILE" ]; then
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    76
  eval $($ARCH_N_OPSYS)
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    77
  SUFFIX=".$ARCH-$OPSYS"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    78
  if [ -f "$OUTFILE$SUFFIX" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    79
    mv "$OUTFILE$SUFFIX" "$OUTFILE"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    80
    [ -n "$NOWRITE" ] && chmod -w "$OUTFILE"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    81
  fi
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4415
diff changeset
    82
fi
3503
390093b95cb0 NOWRITE;
wenzelm
parents: 3055
diff changeset
    83
2302
47e078e60ab1 run-smlnj: SML/NJ startup script (for 1.06 or later).
wenzelm
parents:
diff changeset
    84
exit $RC