lib/scripts/run-polyml
author wenzelm
Mon, 18 Sep 2000 14:49:51 +0200
changeset 10017 e146bbfc38c1
parent 9997 38598a19e701
child 10105 f9be78009930
permissions -rwxr-xr-x
include ANNOUNCE;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3007
e5efa177ee0c removed -norc;
wenzelm
parents: 2936
diff changeset
     1
#!/bin/bash
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     2
#
2314
67bf78c7c725 replaced cat by ucat;
wenzelm
parents: 2301
diff changeset
     3
# $Id$
9789
wenzelm
parents: 9765
diff changeset
     4
# Author: Markus Wenzel, TU Muenchen
wenzelm
parents: 9765
diff changeset
     5
# License: GPL (GNU GENERAL PUBLIC LICENSE)
2314
67bf78c7c725 replaced cat by ucat;
wenzelm
parents: 2301
diff changeset
     6
#
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     7
# Poly/ML startup script.
9977
32955afeb835 unexport exports;
wenzelm
parents: 9789
diff changeset
     8
9997
38598a19e701 keep export of ISABELLE_TMP (!!!);
wenzelm
parents: 9990
diff changeset
     9
export -n INFILE OUTFILE COMPRESS MLTEXT TERMINATE NOWRITE
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    10
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    11
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    12
## diagnostics
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    13
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    14
function fail_out()
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    15
{
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    16
  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    17
  exit 2
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    18
}
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    19
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    20
function check_mlhome_file()
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    21
{
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    22
  if [ ! -f "$1" ]; then
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    23
    echo "Unable to locate $1" >&2
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    24
    echo "Please check your ML_HOME setting!" >&2
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    25
    exit 2
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    26
  fi
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    27
}
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    28
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    29
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
diff changeset
    30
## Poly/ML programs
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    31
9789
wenzelm
parents: 9765
diff changeset
    32
POLY="$ML_HOME/poly"
wenzelm
parents: 9765
diff changeset
    33
DISCGARB="$ML_HOME/discgarb"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    34
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    35
check_mlhome_file "$POLY"
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    36
check_mlhome_file "$DISCGARB"
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    37
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    38
9765
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    39
case "$ML_SYSTEM" in
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    40
  polyml-4.*)
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    41
    EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    42
    ;;
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    43
  *)
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    44
    EXIT="val exit = PolyML.exit;"
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    45
    ;;
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    46
esac
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    47
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    48
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    49
## prepare databases
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    50
3055
5da4afa207ad removed COPYDB flag;
wenzelm
parents: 3007
diff changeset
    51
COPYDB=true
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    52
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    53
if [ -z "$INFILE" ]; then
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
diff changeset
    54
  INFILE="$ML_HOME/ML_dbase"
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    55
  check_mlhome_file "$INFILE"
3055
5da4afa207ad removed COPYDB flag;
wenzelm
parents: 3007
diff changeset
    56
  COPYDB=""
9765
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    57
  MLTEXT="val use = PolyML.use; $EXIT $MLTEXT"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    58
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    59
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    60
if [ -z "$OUTFILE" ]; then
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    61
  DB="$INFILE"
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    62
  ML_OPTIONS="-r $ML_OPTIONS"  
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    63
elif [ "$INFILE" -ef "$OUTFILE" ]; then
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    64
  DB="$INFILE"
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    65
elif [ -n "$COPYDB" ]; then
2936
bd33e7aae062 fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents: 2605
diff changeset
    66
  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
2548
b5d19d99a58d 'rm -f' instead of 'cp -f';
wenzelm
parents: 2400
diff changeset
    67
  cp "$INFILE" "$OUTFILE" || fail_out
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    68
  chmod +w "$OUTFILE" || fail_out
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    69
  DB="$OUTFILE"
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    70
else
2936
bd33e7aae062 fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents: 2605
diff changeset
    71
  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
9789
wenzelm
parents: 9765
diff changeset
    72
  echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    73
  [ -f "$OUTFILE" ] || fail_out
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    74
  DB="$OUTFILE"
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    75
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    76
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    77
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    78
## run it!
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    79
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
    80
if [ -z "$TERMINATE" ]; then
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
    81
  FEEDER_OPTS="-s"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
    82
else
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
    83
  FEEDER_OPTS="-q"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
    84
fi
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
    85
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
diff changeset
    86
DB_INFO=$(ls -l "$DB")
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    87
9789
wenzelm
parents: 9765
diff changeset
    88
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | \
wenzelm
parents: 9765
diff changeset
    89
  { read FPID; "$POLY" $ML_OPTIONS "$DB"; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
wenzelm
parents: 9765
diff changeset
    90
RC="$?"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    91
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
diff changeset
    92
NEW_DB_INFO=$(ls -l "$DB")
9789
wenzelm
parents: 9765
diff changeset
    93
[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && "$DISCGARB" -c "$OUTFILE"
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
    94
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    95
9789
wenzelm
parents: 9765
diff changeset
    96
exit "$RC"