lib/scripts/run-mlworks
author wenzelm
Sun, 15 Oct 2000 19:50:35 +0200
changeset 10220 2a726de6e124
parent 10105 f9be78009930
child 10555 2323ec838401
permissions -rwxr-xr-x
proper symbol markup with \isamath, \isatext; support sub/super scripts:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4426
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
     1
#!/bin/bash
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
     2
#
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
     3
# $Id$
9789
wenzelm
parents: 4505
diff changeset
     4
# Author: Markus Wenzel, TU Muenchen
wenzelm
parents: 4505
diff changeset
     5
# License: GPL (GNU GENERAL PUBLIC LICENSE)
4426
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
     6
#
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
     7
# MLWorks startup script (for 1.0r2 or later).
9977
32955afeb835 unexport exports;
wenzelm
parents: 9868
diff changeset
     8
10105
f9be78009930 added COPYDB argument;
wenzelm
parents: 9997
diff changeset
     9
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
4426
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    10
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    11
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    12
## diagnostics
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    13
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    14
function fail_out()
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    15
{
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    16
  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    17
  exit 2
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    18
}
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    19
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    20
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    21
## prepare databases
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    22
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    23
if [ -z "$INFILE" ]; then
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    24
  EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
4426
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    25
  MLWORKS="mlworks-basis -tty"
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    26
else
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    27
  EXIT=""
9868
580c50fc6559 fixed quotes;
wenzelm
parents: 9789
diff changeset
    28
  MLWORKS="mlimage -load $INFILE -tty"
4426
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    29
fi
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    30
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    31
if [ -z "$OUTFILE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    32
  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: 4433
diff changeset
    33
else
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    34
  COMMIT="fun commit () = (Shell.saveImage (\"$OUTFILE\", false); true);"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    35
  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    36
fi
4426
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    37
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    38
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    39
## run it!
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    40
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    41
MLTEXT="$EXIT $COMMIT $MLTEXT"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    42
MLEXIT="commit();"
4426
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    43
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    44
if [ -z "$TERMINATE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    45
  FEEDER_OPTS="-s"
4426
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    46
else
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    47
  FEEDER_OPTS="-q"
4426
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    48
fi
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    49
9789
wenzelm
parents: 4505
diff changeset
    50
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
9868
580c50fc6559 fixed quotes;
wenzelm
parents: 9789
diff changeset
    51
  { read FPID; "$ML_HOME"/$MLWORKS $ML_OPTIONS 2>&1; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
9789
wenzelm
parents: 4505
diff changeset
    52
RC="$?"
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    53
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4433
diff changeset
    54
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
4426
824cac1bbcfd MLWorks startup script (for 1.0r2 or later).
wenzelm
parents:
diff changeset
    55
9789
wenzelm
parents: 4505
diff changeset
    56
exit "$RC"