lib/scripts/run-polyml
author paulson
Thu, 05 Jun 1997 13:22:25 +0200
changeset 3403 6cc663f6d62e
parent 3055 5da4afa207ad
child 3503 390093b95cb0
permissions -rwxr-xr-x
A slight simplification of optstring The new "simpset" keyword in the "recdef" declaration
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$
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
#
3055
5da4afa207ad removed COPYDB flag;
wenzelm
parents: 3007
diff changeset
     7
# Global vars: INFILE OUTFILE 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
3055
5da4afa207ad removed COPYDB flag;
wenzelm
parents: 3007
diff changeset
    34
COPYDB=true
2349
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"
3055
5da4afa207ad removed COPYDB flag;
wenzelm
parents: 3007
diff changeset
    38
  MLTEXT="val use = PolyML.use; val exit = PolyML.exit; $MLTEXT"
5da4afa207ad removed COPYDB flag;
wenzelm
parents: 3007
diff changeset
    39
  COPYDB=""
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
2936
bd33e7aae062 fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents: 2605
diff changeset
    48
  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
2548
b5d19d99a58d 'rm -f' instead of 'cp -f';
wenzelm
parents: 2400
diff changeset
    49
  cp "$INFILE" "$OUTFILE" || fail_out
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    50
  chmod +w "$OUTFILE" || fail_out
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    51
  DB="$OUTFILE"
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    52
else
2936
bd33e7aae062 fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents: 2605
diff changeset
    53
  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    54
  echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | $POLY -r "$INFILE"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    55
  [ -f "$OUTFILE" ] || fail_out
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    56
  DB="$OUTFILE"
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
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    65
if [ -n "$TERMINATE" ]; then
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    66
  echo "$MLTEXT" | $START_POLY
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    67
  RC=$?
2605
1effe7413486 tuned startup;
wenzelm
parents: 2548
diff changeset
    68
elif [ -z "$MLTEXT" ]; then
1effe7413486 tuned startup;
wenzelm
parents: 2548
diff changeset
    69
  sh -c "$ISABELLE_HOME/lib/Tools/symbolinput | $START_POLY"
1effe7413486 tuned startup;
wenzelm
parents: 2548
diff changeset
    70
  RC=$?
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    71
else
2605
1effe7413486 tuned startup;
wenzelm
parents: 2548
diff changeset
    72
  sh -c "{ echo '$MLTEXT'; $ISABELLE_HOME/lib/Tools/symbolinput; } | $START_POLY"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    73
  RC=$?
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    74
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    75
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
diff changeset
    76
NEW_DB_INFO=$(ls -l "$DB")
2605
1effe7413486 tuned startup;
wenzelm
parents: 2548
diff changeset
    77
[ -n "$OUTFILE" -a "$DB_INFO" != "$NEW_DB_INFO" ] && $DISCGARB "$OUTFILE"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    78
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    79
exit $RC