lib/scripts/run-polyml
author wenzelm
Thu, 23 Jan 1997 18:10:29 +0100
changeset 2548 b5d19d99a58d
parent 2400 4b08766bc9d1
child 2605 1effe7413486
permissions -rwxr-xr-x
'rm -f' instead of 'cp -f';
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
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
diff changeset
    20
## Poly/ML programs
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    21
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    22
POLY=$ML_HOME/poly
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    23
DISCGARB=$ML_HOME/discgarb
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    24
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    25
case "$ML_SYSTEM" in
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    26
  polyml-3.*)
2314
67bf78c7c725 replaced cat by ucat;
wenzelm
parents: 2301
diff changeset
    27
    DISCGARB="$DISCGARB -c"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    28
    ;;
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    29
esac
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    30
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    31
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    32
## prepare databases
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    33
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    34
MLINIT=""
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    35
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    36
if [ -z "$INFILE" ]; then
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
diff changeset
    37
  INFILE="$ML_HOME/ML_dbase"
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    38
  MLINIT="val use = PolyML.use; val exit = PolyML.exit; fun init_database () = ();"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    39
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    40
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    41
if [ -z "$OUTFILE" ]; then
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    42
  DB="$INFILE"
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    43
  ML_OPTIONS="-r $ML_OPTIONS"  
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    44
elif [ "$INFILE" -ef "$OUTFILE" ]; then
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    45
  DB="$INFILE"
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    46
elif [ -n "$COPYDB" ]; then
2548
b5d19d99a58d 'rm -f' instead of 'cp -f';
wenzelm
parents: 2400
diff changeset
    47
  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out }
b5d19d99a58d 'rm -f' instead of 'cp -f';
wenzelm
parents: 2400
diff changeset
    48
  cp "$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"
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
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
else
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
diff changeset
    71
  { echo "$MLTEXT"; $ISABELLE_HOME/lib/Tools/symbolinput } | $START_POLY
2301
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
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    74
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
diff changeset
    75
NEW_DB_INFO=$(ls -l "$DB")
2389
d472c732bc21 now discgarb called only for changed databases;
wenzelm
parents: 2349
diff changeset
    76
[ $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
    77
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    78
exit $RC