# HG changeset patch # User wenzelm # Date 1375387003 -7200 # Node ID 980ca3d6ded401ceb8dc6d60708187ada1be2cf9 # Parent 72bbdc64d0de554420bb763cc43d1db783fa7dda specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options; diff -r 72bbdc64d0de -r 980ca3d6ded4 lib/scripts/run-polyml-5.5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/scripts/run-polyml-5.5.1 Thu Aug 01 21:56:43 2013 +0200 @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# :mode=shellscript: +# +# Author: Makarius +# +# Startup script for Poly/ML 5.5.1. + +export -n INFILE OUTFILE MLTEXT TERMINATE NOWRITE + + +## diagnostics + +function fail() +{ + echo "$1" >&2 + exit 2 +} + +function fail_out() +{ + fail "Unable to create output heap file: \"$OUTFILE\"" +} + +function check_file() +{ + [ ! -f "$1" ] && fail "Unable to locate \"$1\"" +} + + +## compiler executables and libraries + +[ -z "$ML_HOME" ] && fail "Missing ML installation (ML_HOME)" + +POLY="$ML_HOME/poly" +check_file "$POLY" + +librarypath "$ML_HOME" + + + +## prepare databases + +if [ -z "$INFILE" ]; then + INIT="" + EXIT="fun exit rc : unit = Posix.Process.exit (Word8.fromInt rc);" +else + check_file "$INFILE" + INIT="(Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ())); PolyML.SaveState.loadState \"$INFILE\" handle exn => (TextIO.output (TextIO.stdErr, General.exnMessage exn ^ \": $INFILE\\n\"); Posix.Process.exit 0w1));" + EXIT="" +fi + +if [ -z "$OUTFILE" ]; then + COMMIT='fun commit () = false;' + MLEXIT="" +else + COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true) handle exn => (TextIO.output (TextIO.stdErr, General.exnMessage exn ^ \": $OUTFILE\\n\"); Posix.Process.exit 0w1);" + [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } + MLEXIT="commit();" +fi + + +## run it! + +MLTEXT="$INIT $EXIT $COMMIT $MLTEXT" + +if [ -n "$TERMINATE" -a -z "$MLEXIT" ]; then + "$POLY" -q -i $ML_OPTIONS --eval "$MLTEXT" --error-exit