lib/scripts/run-mlworks
author berghofe
Thu, 30 Jul 1998 15:49:18 +0200
changeset 5213 0aa62210e67c
parent 4505 4a2c872b6513
child 9789 7e5e6c47c0b5
permissions -rwxr-xr-x
Script that adapts theories and proof scripts to new datatype package.

#!/bin/bash
#
# $Id$
#
# MLWorks startup script (for 1.0r2 or later).
#
# Global vars: INFILE OUTFILE MLTEXT TERMINATE NOWRITE ISABELLE_TMP,
# and from settings


## diagnostics

function fail_out()
{
  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
  exit 2
}


## prepare databases

if [ -z "$INFILE" ]; then
  EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
  MLWORKS="mlworks-basis -tty"
else
  EXIT=""
  MLWORKS="mlimage -load $INFILE -tty"
fi

if [ -z "$OUTFILE" ]; then
  COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);'
else
  COMMIT="fun commit () = (Shell.saveImage (\"$OUTFILE\", false); true);"
  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
fi


## run it!

MLTEXT="$EXIT $COMMIT $MLTEXT"
MLEXIT="commit();"

if [ -z "$TERMINATE" ]; then
  FEEDER_OPTS="-s"
else
  FEEDER_OPTS="-q"
fi

$ISABELLE_HOME/lib/scripts/feeder -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
  { read FPID; $ML_HOME/$MLWORKS $ML_OPTIONS 2>&1; RC=$?; kill -HUP $FPID; exit $RC; }
RC=$?

[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"

exit $RC