bin/isabelle-process
author wenzelm
Wed, 15 Apr 2009 11:14:48 +0200
changeset 30895 bad26d8f0adf
parent 28935 7c6b0850d240
child 31315 3c7b40548a84
permissions -rwxr-xr-x
updated for Isabelle2009;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
     2
#
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
     3
# Author: Markus Wenzel, TU Muenchen
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
     4
#
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
     5
# Isabelle process startup script.
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
     6
15843
d5bd4a18ce70 improved handling of symlinks;
wenzelm
parents: 15801
diff changeset
     7
if [ -L "$0" ]; then
d5bd4a18ce70 improved handling of symlinks;
wenzelm
parents: 15801
diff changeset
     8
  TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
15967
f9163c6f69d6 proper treatment of directory links;
wenzelm
parents: 15864
diff changeset
     9
  exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
15843
d5bd4a18ce70 improved handling of symlinks;
wenzelm
parents: 15801
diff changeset
    10
fi
d5bd4a18ce70 improved handling of symlinks;
wenzelm
parents: 15801
diff changeset
    11
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    12
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    13
## settings
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    14
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    15
PRG="$(basename "$0")"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    16
15967
f9163c6f69d6 proper treatment of directory links;
wenzelm
parents: 15864
diff changeset
    17
ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
f9163c6f69d6 proper treatment of directory links;
wenzelm
parents: 15864
diff changeset
    18
source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    19
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    20
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    21
## diagnostics
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    22
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    23
function usage()
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    24
{
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    25
  echo
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    26
  echo "Usage: $PRG [OPTIONS] [INPUT] [OUTPUT]"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    27
  echo
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    28
  echo "  Options are:"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    29
  echo "    -C           tell ML system to copy output image"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    30
  echo "    -I           startup Isar interaction mode"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    31
  echo "    -P           startup Proof General interaction mode"
20929
wenzelm
parents: 20923
diff changeset
    32
  echo "    -S           secure mode -- disallow critical operations"
16101
37471d84d353 Add back rudely removed and popular -X option.
aspinall
parents: 15967
diff changeset
    33
  echo "    -X           startup PGIP interaction mode"
28043
4d05f04cc671 refined option -W: output stream;
wenzelm
parents: 27201
diff changeset
    34
  echo "    -W OUTPUT    startup process wrapper, with messages going to OUTPUT stream"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    35
  echo "    -c           tell ML system to compress output image"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    36
  echo "    -e MLTEXT    pass MLTEXT to the ML session"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    37
  echo "    -f           pass 'Session.finish();' to the ML session"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    38
  echo "    -m MODE      add print mode for output"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    39
  echo "    -q           non-interactive session"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    40
  echo "    -r           open heap file read-only"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    41
  echo "    -u           pass 'use\"ROOT.ML\";' to the ML session"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    42
  echo "    -w           reset write permissions on OUTPUT"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    43
  echo
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    44
  echo "  INPUT (default \"$ISABELLE_LOGIC\") and OUTPUT specify in/out heaps."
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    45
  echo "  These are either names to be searched in the Isabelle path, or"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    46
  echo "  actual file names (containing at least one /)."
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    47
  echo "  If INPUT is \"RAW_ML_SYSTEM\", just start the bare bones ML system."
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    48
  echo
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    49
  exit 1
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    50
}
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    51
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    52
function fail()
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    53
{
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    54
  echo "$1" >&2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    55
  exit 2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    56
}
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    57
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    58
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    59
## process command line
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    60
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    61
# options
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    62
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    63
COPYDB=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    64
ISAR=false
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    65
PROOFGENERAL=""
20923
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    66
SECURE=""
28043
4d05f04cc671 refined option -W: output stream;
wenzelm
parents: 27201
diff changeset
    67
WRAPPER_OUTPUT=""
25523
08b0feb07239 replaced option -p by -W (process wrapper);
wenzelm
parents: 25504
diff changeset
    68
PGIP=""
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    69
COMPRESS=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    70
MLTEXT=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    71
MODES=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    72
TERMINATE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    73
READONLY=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    74
NOWRITE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    75
28043
4d05f04cc671 refined option -W: output stream;
wenzelm
parents: 27201
diff changeset
    76
while getopts "CIPSW:Xce:fm:qruw" OPT
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    77
do
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    78
  case "$OPT" in
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    79
    C)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    80
      COPYDB=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    81
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    82
    I)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    83
      ISAR=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    84
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    85
    P)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    86
      PROOFGENERAL=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    87
      ;;
20923
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    88
    S)
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    89
      SECURE=true
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    90
      ;;
25523
08b0feb07239 replaced option -p by -W (process wrapper);
wenzelm
parents: 25504
diff changeset
    91
    W)
28043
4d05f04cc671 refined option -W: output stream;
wenzelm
parents: 27201
diff changeset
    92
      WRAPPER_OUTPUT="$OPTARG"
25523
08b0feb07239 replaced option -p by -W (process wrapper);
wenzelm
parents: 25504
diff changeset
    93
      ;;
16101
37471d84d353 Add back rudely removed and popular -X option.
aspinall
parents: 15967
diff changeset
    94
    X)
37471d84d353 Add back rudely removed and popular -X option.
aspinall
parents: 15967
diff changeset
    95
      PGIP=true
37471d84d353 Add back rudely removed and popular -X option.
aspinall
parents: 15967
diff changeset
    96
      ;;
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    97
    c)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    98
      COMPRESS=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    99
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   100
    e)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   101
      MLTEXT="$MLTEXT $OPTARG"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   102
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   103
    f)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   104
      MLTEXT="$MLTEXT Session.finish();"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   105
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   106
    m)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   107
      if [ -z "$MODES" ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   108
        MODES="\"$OPTARG\""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   109
      else
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   110
        MODES="\"$OPTARG\", $MODES"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   111
      fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   112
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   113
    q)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   114
      TERMINATE=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   115
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   116
    r)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   117
      READONLY=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   118
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   119
    u)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   120
      MLTEXT="$MLTEXT use\"ROOT.ML\";"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   121
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   122
    w)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   123
      NOWRITE=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   124
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   125
    \?)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   126
      usage
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   127
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   128
  esac
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   129
done
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   130
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   131
shift $(($OPTIND - 1))
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   132
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   133
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   134
# args
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   135
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   136
INPUT=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   137
OUTPUT=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   138
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   139
if [ "$#" -ge 1 ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   140
  INPUT="$1"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   141
  shift
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   142
fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   143
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   144
if [ "$#" -ge 1 ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   145
  OUTPUT="$1"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   146
  shift
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   147
fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   148
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   149
[ "$#" -ne 0 ] && { echo "Bad args: $*"; usage; }
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   150
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   151
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   152
## check ML system
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   153
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   154
[ -z "$ML_SYSTEM" ] && fail "Missing ML system settings! Unable to run Isabelle."
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   155
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   156
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   157
## input heap file
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   158
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   159
[ -z "$INPUT" ] && INPUT="$ISABELLE_LOGIC"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   160
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   161
case "$INPUT" in
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   162
  RAW_ML_SYSTEM)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   163
    INFILE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   164
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   165
  */*)
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   166
    INFILE="$INPUT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   167
    [ ! -f "$INFILE" ] && fail "Bad heap file: \"$INFILE\""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   168
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   169
  *)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   170
    INFILE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   171
    ISA_PATH=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   172
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   173
    ORIG_IFS="$IFS"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   174
    IFS=":"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   175
    for DIR in $ISABELLE_PATH
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   176
    do
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   177
      DIR="$DIR/$ML_IDENTIFIER"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   178
      ISA_PATH="$ISA_PATH  $DIR\n"
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   179
      [ -z "$INFILE" -a -f "$DIR/$INPUT" ] && INFILE="$DIR/$INPUT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   180
    done
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   181
    IFS="$ORIG_IFS"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   182
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   183
    if [ -z "$INFILE" ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   184
      echo "Unknown logic \"$INPUT\" -- no heap file found in:" >&2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   185
      echo -ne "$ISA_PATH" >&2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   186
      exit 2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   187
    fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   188
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   189
esac
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   190
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   191
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   192
## output heap file
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   193
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   194
case "$OUTPUT" in
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   195
  "")
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   196
    [ -z "$READONLY" -a -w "$INFILE" ] && OUTFILE="$INFILE"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   197
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   198
  */*)
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   199
    OUTFILE="$OUTPUT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   200
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   201
  *)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   202
    mkdir -p "$ISABELLE_OUTPUT"
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   203
    OUTFILE="$ISABELLE_OUTPUT/$OUTPUT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   204
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   205
esac
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   206
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   207
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   208
## prepare tmp directory
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   209
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   210
[ -z "$ISABELLE_TMP_PREFIX" ] && ISABELLE_TMP_PREFIX=/tmp/isabelle
16874
wenzelm
parents: 16817
diff changeset
   211
ISABELLE_PID="$$"
17792
4a34fd6884b1 support ML_SUFFIX;
wenzelm
parents: 16874
diff changeset
   212
ISABELLE_TMP="$ISABELLE_TMP_PREFIX$ISABELLE_PID"
16874
wenzelm
parents: 16817
diff changeset
   213
mkdir -p "$ISABELLE_TMP"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   214
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   215
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   216
## run it!
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   217
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   218
ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   219
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   220
[ -n "$MODES" ] && MLTEXT="print_mode := [$MODES]; $MLTEXT"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   221
20923
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
   222
[ -n "$SECURE" ] && MLTEXT="$MLTEXT Secure.set_secure ();"
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
   223
25645
b2ed983a5e80 non-ML session: run with 'nice', to prevent isabelle process from flooding interactive front-ends (ProofGeneral/XEmacs etc.)
wenzelm
parents: 25523
diff changeset
   224
NICE="nice"
28043
4d05f04cc671 refined option -W: output stream;
wenzelm
parents: 27201
diff changeset
   225
if [ -n "$WRAPPER_OUTPUT" ]; then
28138
03e5196b1559 check WRAPPER_OUTPUT node type;
wenzelm
parents: 28043
diff changeset
   226
  [ "$WRAPPER_OUTPUT" = "-" -o -p "$WRAPPER_OUTPUT" ] || fail "Bad named pipe: $WRAPPER_OUTPUT"
28043
4d05f04cc671 refined option -W: output stream;
wenzelm
parents: 27201
diff changeset
   227
  MLTEXT="$MLTEXT; IsabelleProcess.init \"$WRAPPER_OUTPUT\";"
25523
08b0feb07239 replaced option -p by -W (process wrapper);
wenzelm
parents: 25504
diff changeset
   228
elif [ -n "$PGIP" ]; then
21639
8ab7c4dbb524 Forward compatibility with new Proof General module.
aspinall
parents: 20929
diff changeset
   229
  MLTEXT="$MLTEXT; ProofGeneralPgip.init_pgip $ISAR;"
16101
37471d84d353 Add back rudely removed and popular -X option.
aspinall
parents: 15967
diff changeset
   230
elif [ -n "$PROOFGENERAL" ]; then
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   231
  MLTEXT="$MLTEXT; ProofGeneral.init $ISAR;"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   232
elif [ "$ISAR" = true ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   233
  MLTEXT="$MLTEXT; Isar.main();"
25645
b2ed983a5e80 non-ML session: run with 'nice', to prevent isabelle process from flooding interactive front-ends (ProofGeneral/XEmacs etc.)
wenzelm
parents: 25523
diff changeset
   234
else
b2ed983a5e80 non-ML session: run with 'nice', to prevent isabelle process from flooding interactive front-ends (ProofGeneral/XEmacs etc.)
wenzelm
parents: 25523
diff changeset
   235
  NICE=""
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   236
fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   237
16874
wenzelm
parents: 16817
diff changeset
   238
export INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE \
wenzelm
parents: 16817
diff changeset
   239
  ISABELLE_PID ISABELLE_TMP
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   240
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   241
if [ -f "$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM" ]; then
25645
b2ed983a5e80 non-ML session: run with 'nice', to prevent isabelle process from flooding interactive front-ends (ProofGeneral/XEmacs etc.)
wenzelm
parents: 25523
diff changeset
   242
  $NICE "$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   243
else
25645
b2ed983a5e80 non-ML session: run with 'nice', to prevent isabelle process from flooding interactive front-ends (ProofGeneral/XEmacs etc.)
wenzelm
parents: 25523
diff changeset
   244
  $NICE "$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   245
fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   246
RC="$?"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   247
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   248
rmdir "$ISABELLE_TMP"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   249
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   250
exit "$RC"