bin/isabelle-process
author wenzelm
Fri, 17 May 2013 19:04:52 +0200
changeset 52056 fc458f304f93
parent 52054 eaf17514aabd
permissions -rwxr-xr-x
added isabelle-process option -o;
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 "    -I           startup Isar interaction mode"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    30
  echo "    -P           startup Proof General interaction mode"
20929
wenzelm
parents: 20923
diff changeset
    31
  echo "    -S           secure mode -- disallow critical operations"
45028
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 38253
diff changeset
    32
  echo "    -T ADDR      startup process wrapper, with socket address"
38253
3d4e521014f7 Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents: 34116
diff changeset
    33
  echo "    -W IN:OUT    startup process wrapper, with input/output fifos"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    34
  echo "    -e MLTEXT    pass MLTEXT to the ML session"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    35
  echo "    -m MODE      add print mode for output"
52056
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
    36
  echo "    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    37
  echo "    -q           non-interactive session"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    38
  echo "    -r           open heap file read-only"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    39
  echo "    -w           reset write permissions on OUTPUT"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    40
  echo
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    41
  echo "  INPUT (default \"$ISABELLE_LOGIC\") and OUTPUT specify in/out heaps."
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    42
  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
    43
  echo "  actual file names (containing at least one /)."
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    44
  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
    45
  echo
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    46
  exit 1
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    47
}
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    48
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    49
function fail()
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
  echo "$1" >&2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    52
  exit 2
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
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    55
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    56
## process command line
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
# options
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    59
51948
cb5dbc9a06f9 load options for regular isabelle-process, not just for Isar loop (relevant for numerous low-level tools) -- NB: Isabelle_Process manages options via protocol message;
wenzelm
parents: 51938
diff changeset
    60
ISAR=""
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    61
PROOFGENERAL=""
20923
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    62
SECURE=""
45028
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 38253
diff changeset
    63
WRAPPER_SOCKET=""
38253
3d4e521014f7 Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents: 34116
diff changeset
    64
WRAPPER_FIFOS=""
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    65
MLTEXT=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    66
MODES=""
52056
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
    67
declare -a SYSTEM_OPTIONS=()
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    68
TERMINATE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    69
READONLY=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    70
NOWRITE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    71
52056
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
    72
while getopts "IPST:W:e:m:o:qrw" OPT
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    73
do
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    74
  case "$OPT" in
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    75
    I)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    76
      ISAR=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    77
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    78
    P)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    79
      PROOFGENERAL=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    80
      ;;
20923
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    81
    S)
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    82
      SECURE=true
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    83
      ;;
45028
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 38253
diff changeset
    84
    T)
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 38253
diff changeset
    85
      WRAPPER_SOCKET="$OPTARG"
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 38253
diff changeset
    86
      ;;
25523
08b0feb07239 replaced option -p by -W (process wrapper);
wenzelm
parents: 25504
diff changeset
    87
    W)
38253
3d4e521014f7 Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents: 34116
diff changeset
    88
      WRAPPER_FIFOS="$OPTARG"
25523
08b0feb07239 replaced option -p by -W (process wrapper);
wenzelm
parents: 25504
diff changeset
    89
      ;;
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    90
    e)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    91
      MLTEXT="$MLTEXT $OPTARG"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    92
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    93
    m)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    94
      if [ -z "$MODES" ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    95
        MODES="\"$OPTARG\""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    96
      else
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    97
        MODES="\"$OPTARG\", $MODES"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    98
      fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    99
      ;;
52056
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
   100
    o)
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
   101
      SYSTEM_OPTIONS["${#SYSTEM_OPTIONS[@]}"]="$OPTARG"
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
   102
      ;;
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   103
    q)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   104
      TERMINATE=true
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
    r)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   107
      READONLY=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   108
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   109
    w)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   110
      NOWRITE=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   111
      ;;
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
      usage
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   114
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   115
  esac
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   116
done
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   117
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   118
shift $(($OPTIND - 1))
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   119
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   120
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   121
# args
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   122
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   123
INPUT=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   124
OUTPUT=""
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
if [ "$#" -ge 1 ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   127
  INPUT="$1"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   128
  shift
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   129
fi
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
if [ "$#" -ge 1 ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   132
  OUTPUT="$1"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   133
  shift
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   134
fi
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
[ "$#" -ne 0 ] && { echo "Bad args: $*"; usage; }
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   137
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
## check ML system
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   140
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   141
[ -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
   142
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
## input heap file
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   145
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   146
[ -z "$INPUT" ] && INPUT="$ISABELLE_LOGIC"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   147
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   148
case "$INPUT" in
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   149
  RAW_ML_SYSTEM)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   150
    INFILE=""
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
  */*)
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   153
    INFILE="$INPUT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   154
    [ ! -f "$INFILE" ] && fail "Bad heap file: \"$INFILE\""
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
    INFILE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   158
    ISA_PATH=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   159
32390
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32322
diff changeset
   160
    splitarray ":" "$ISABELLE_PATH"; PATHS=("${SPLITARRAY[@]}")
32322
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 31797
diff changeset
   161
    for DIR in "${PATHS[@]}"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   162
    do
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   163
      DIR="$DIR/$ML_IDENTIFIER"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   164
      ISA_PATH="$ISA_PATH  $DIR\n"
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   165
      [ -z "$INFILE" -a -f "$DIR/$INPUT" ] && INFILE="$DIR/$INPUT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   166
    done
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   167
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   168
    if [ -z "$INFILE" ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   169
      echo "Unknown logic \"$INPUT\" -- no heap file found in:" >&2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   170
      echo -ne "$ISA_PATH" >&2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   171
      exit 2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   172
    fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   173
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   174
esac
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   175
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   176
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   177
## output heap file
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   178
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   179
case "$OUTPUT" in
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   180
  "")
33920
d4d430dfabc6 double check file permissions of write-back image -- more robust for root or administrator on Cygwin;
wenzelm
parents: 32390
diff changeset
   181
    if [ -z "$READONLY" -a -w "$INFILE" ]; then
d4d430dfabc6 double check file permissions of write-back image -- more robust for root or administrator on Cygwin;
wenzelm
parents: 32390
diff changeset
   182
      perl -e "exit (((stat('$INFILE'))[2] & 0222) != 0 ? 0 : 1);" && OUTFILE="$INFILE"
d4d430dfabc6 double check file permissions of write-back image -- more robust for root or administrator on Cygwin;
wenzelm
parents: 32390
diff changeset
   183
    fi
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   184
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   185
  */*)
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   186
    OUTFILE="$OUTPUT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   187
    ;;
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
    mkdir -p "$ISABELLE_OUTPUT"
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   190
    OUTFILE="$ISABELLE_OUTPUT/$OUTPUT"
11550
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
esac
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
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   195
## prepare tmp directory
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   196
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   197
[ -z "$ISABELLE_TMP_PREFIX" ] && ISABELLE_TMP_PREFIX=/tmp/isabelle
16874
wenzelm
parents: 16817
diff changeset
   198
ISABELLE_PID="$$"
17792
4a34fd6884b1 support ML_SUFFIX;
wenzelm
parents: 16874
diff changeset
   199
ISABELLE_TMP="$ISABELLE_TMP_PREFIX$ISABELLE_PID"
16874
wenzelm
parents: 16817
diff changeset
   200
mkdir -p "$ISABELLE_TMP"
11550
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
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   203
## run it!
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
ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   206
45056
bbd7eac14df3 augment existing print mode;
wenzelm
parents: 45028
diff changeset
   207
[ -n "$MODES" ] && MLTEXT="Unsynchronized.change print_mode (append [$MODES]); $MLTEXT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   208
51948
cb5dbc9a06f9 load options for regular isabelle-process, not just for Isar loop (relevant for numerous low-level tools) -- NB: Isabelle_Process manages options via protocol message;
wenzelm
parents: 51938
diff changeset
   209
[ -n "$SECURE" ] && MLTEXT="$MLTEXT; Secure.set_secure ();"
20923
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
   210
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
   211
NICE="nice"
38253
3d4e521014f7 Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents: 34116
diff changeset
   212
45028
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 38253
diff changeset
   213
if [ -n "$WRAPPER_SOCKET" ]; then
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 38253
diff changeset
   214
  MLTEXT="$MLTEXT; Isabelle_Process.init_socket \"$WRAPPER_SOCKET\";"
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 38253
diff changeset
   215
elif [ -n "$WRAPPER_FIFOS" ]; then
38253
3d4e521014f7 Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents: 34116
diff changeset
   216
  splitarray ":" "$WRAPPER_FIFOS"; FIFOS=("${SPLITARRAY[@]}")
3d4e521014f7 Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents: 34116
diff changeset
   217
  [ "${#FIFOS[@]}" -eq 2 ] || fail "Expected IN:OUT fifo specification"
3d4e521014f7 Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents: 34116
diff changeset
   218
  [ -p "${FIFOS[0]}" ] || fail "Bad input fifo: ${FIFOS[0]}"
3d4e521014f7 Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents: 34116
diff changeset
   219
  [ -p "${FIFOS[1]}" ] || fail "Bad output fifo: ${FIFOS[1]}"
45028
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 38253
diff changeset
   220
  MLTEXT="$MLTEXT; Isabelle_Process.init_fifos \"${FIFOS[0]}\" \"${FIFOS[1]}\";"
51948
cb5dbc9a06f9 load options for regular isabelle-process, not just for Isar loop (relevant for numerous low-level tools) -- NB: Isabelle_Process manages options via protocol message;
wenzelm
parents: 51938
diff changeset
   221
else
51952
4517ceb545c1 re-init ISABELLE_PROCESS_OPTIONS to allow nested ISABELLE_PROCESS invocations, e.g. HOL-Mutabelle-ex;
wenzelm
parents: 51948
diff changeset
   222
  ISABELLE_PROCESS_OPTIONS="$ISABELLE_TMP/options"
52056
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
   223
  "$ISABELLE_TOOL" options -x "$ISABELLE_PROCESS_OPTIONS" -- "${SYSTEM_OPTIONS[@]}" || \
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
   224
    fail "Failed to retrieve Isabelle system options"
51964
f1c1d8637216 clean startup of RAW session;
wenzelm
parents: 51952
diff changeset
   225
  if [ "$INPUT" != RAW_ML_SYSTEM -a "$INPUT" != RAW ]; then
51948
cb5dbc9a06f9 load options for regular isabelle-process, not just for Isar loop (relevant for numerous low-level tools) -- NB: Isabelle_Process manages options via protocol message;
wenzelm
parents: 51938
diff changeset
   226
    MLTEXT="Options.load_default () handle _ => exit 2; $MLTEXT"
cb5dbc9a06f9 load options for regular isabelle-process, not just for Isar loop (relevant for numerous low-level tools) -- NB: Isabelle_Process manages options via protocol message;
wenzelm
parents: 51938
diff changeset
   227
  fi
51938
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51932
diff changeset
   228
  if [ -n "$PROOFGENERAL" ]; then
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51932
diff changeset
   229
    MLTEXT="$MLTEXT; ProofGeneral.init ();"
51948
cb5dbc9a06f9 load options for regular isabelle-process, not just for Isar loop (relevant for numerous low-level tools) -- NB: Isabelle_Process manages options via protocol message;
wenzelm
parents: 51938
diff changeset
   230
  elif [ -n "$ISAR" ]; then
cb5dbc9a06f9 load options for regular isabelle-process, not just for Isar loop (relevant for numerous low-level tools) -- NB: Isabelle_Process manages options via protocol message;
wenzelm
parents: 51938
diff changeset
   231
    MLTEXT="$MLTEXT; Isar.main ();"
51938
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51932
diff changeset
   232
  else
51948
cb5dbc9a06f9 load options for regular isabelle-process, not just for Isar loop (relevant for numerous low-level tools) -- NB: Isabelle_Process manages options via protocol message;
wenzelm
parents: 51938
diff changeset
   233
    NICE=""
51938
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51932
diff changeset
   234
  fi
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   235
fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   236
48698
2585042b1a30 pass Isabelle/Scala system options into ML process of Isar tty or build jobs;
wenzelm
parents: 45056
diff changeset
   237
export INFILE OUTFILE MLTEXT TERMINATE NOWRITE ISABELLE_PID ISABELLE_TMP ISABELLE_PROCESS_OPTIONS
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   238
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   239
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
   240
  $NICE "$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   241
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
   242
  $NICE "$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   243
fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   244
RC="$?"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   245
48698
2585042b1a30 pass Isabelle/Scala system options into ML process of Isar tty or build jobs;
wenzelm
parents: 45056
diff changeset
   246
[ -n "$ISABELLE_PROCESS_OPTIONS" ] && rm -f "$ISABELLE_PROCESS_OPTIONS"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   247
rmdir "$ISABELLE_TMP"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   248
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   249
exit "$RC"