lib/scripts/run-polyml
author wenzelm
Fri, 13 Dec 1996 17:48:03 +0100
changeset 2389 d472c732bc21
parent 2349 e9475a7be4ad
child 2400 4b08766bc9d1
permissions -rwxr-xr-x
now discgarb called only for changed databases;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
     1
#!/bin/bash -norc
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$
67bf78c7c725 replaced cat by ucat;
wenzelm
parents: 2301
diff changeset
     4
#
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     5
# Poly/ML startup script.
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     6
#
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
     7
# Global vars: INFILE OUTFILE COPYDB MLTEXT TERMINATE,
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     8
# and from settings
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     9
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    10
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    11
## diagnostics
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    12
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    13
function fail_out()
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    14
{
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    15
  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    16
  exit 2
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    17
}
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    18
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    19
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    20
## locations and settings
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    21
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    22
ML_DBASE=$ML_HOME/ML_dbase
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    23
POLY=$ML_HOME/poly
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    24
DISCGARB=$ML_HOME/discgarb
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    25
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    26
case "$ML_SYSTEM" in
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    27
  polyml-3.*)
2314
67bf78c7c725 replaced cat by ucat;
wenzelm
parents: 2301
diff changeset
    28
    DISCGARB="$DISCGARB -c"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    29
    ;;
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    30
esac
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    31
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    32
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    33
## prepare databases
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    34
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    35
MLINIT=""
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    36
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    37
if [ -z "$INFILE" ]; then
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    38
  INFILE="$ML_DBASE"
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    39
  MLINIT="val use = PolyML.use; val exit = PolyML.exit; fun init_database () = ();"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    40
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    41
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    42
if [ -z "$OUTFILE" ]; then
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    43
  DB="$INFILE"
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    44
  ML_OPTIONS="-r $ML_OPTIONS"  
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    45
elif [ "$INFILE" -ef "$OUTFILE" ]; then
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    46
  DB="$INFILE"
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    47
elif [ -n "$COPYDB" ]; then
2389
d472c732bc21 now discgarb called only for changed databases;
wenzelm
parents: 2349
diff changeset
    48
  cp -f "$INFILE" "$OUTFILE" || fail_out
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    49
  chmod +w "$OUTFILE" || fail_out
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    50
  DB="$OUTFILE"
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    51
else
2389
d472c732bc21 now discgarb called only for changed databases;
wenzelm
parents: 2349
diff changeset
    52
  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out }
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    53
  echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | $POLY -r "$INFILE"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    54
  [ -f "$OUTFILE" ] || fail_out
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    55
  DB="$OUTFILE"
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    56
  MLINIT="$MLINIT init_database ();"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    57
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    58
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    59
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    60
## run it!
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    61
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    62
START_POLY="$POLY $ML_OPTIONS $DB"
2389
d472c732bc21 now discgarb called only for changed databases;
wenzelm
parents: 2349
diff changeset
    63
DB_INFO=$(ls -l $DB)
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    64
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    65
[ -n "$MLINIT" ] && MLTEXT="$MLINIT $MLTEXT"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    66
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    67
if [ -n "$TERMINATE" ]; then
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    68
  echo "$MLTEXT" | $START_POLY
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    69
  RC=$?
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    70
elif [ -z "$MLTEXT" ]; then
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    71
  $START_POLY
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    72
  RC=$?
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    73
else
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    74
  { echo "$MLTEXT"; $ISABELLE_HOME/lib/scripts/ucat } | $START_POLY
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    75
  RC=$?
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    76
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    77
2389
d472c732bc21 now discgarb called only for changed databases;
wenzelm
parents: 2349
diff changeset
    78
NEW_DB_INFO=$(ls -l $DB)
d472c732bc21 now discgarb called only for changed databases;
wenzelm
parents: 2349
diff changeset
    79
[ $RC -eq 0 -a -n "$OUTFILE" -a "$DB_INFO" != "$NEW_DB_INFO" ] && $DISCGARB "$OUTFILE"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    80
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    81
exit $RC