bin/isabelle_process
author wenzelm
Wed, 30 Dec 2015 21:57:52 +0100
changeset 62002 f1599e98c4d0
parent 61319 d84b4d39bce1
child 62475 43e64c770f28
permissions -rwxr-xr-x
isabelle update_cartouches -c -t;
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:"
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
    29
  echo "    -O           system options from given YXML file"
59350
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 58846
diff changeset
    30
  echo "    -P SOCKET    startup process wrapper via TCP socket"
20929
wenzelm
parents: 20923
diff changeset
    31
  echo "    -S           secure mode -- disallow critical operations"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    32
  echo "    -e MLTEXT    pass MLTEXT to the ML session"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    33
  echo "    -m MODE      add print mode for output"
52056
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
    34
  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
    35
  echo "    -q           non-interactive session"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    36
  echo "    -r           open heap file read-only"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    37
  echo "    -w           reset write permissions on OUTPUT"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    38
  echo
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    39
  echo "  INPUT (default \"$ISABELLE_LOGIC\") and OUTPUT specify in/out heaps."
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    40
  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
    41
  echo "  actual file names (containing at least one /)."
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    42
  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
    43
  echo
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    44
  exit 1
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    45
}
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    46
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    47
function fail()
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
  echo "$1" >&2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    50
  exit 2
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
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
## process command line
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
# options
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    57
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
    58
OPTIONS_FILE=""
59350
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 58846
diff changeset
    59
PROCESS_SOCKET=""
20923
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    60
SECURE=""
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    61
MLTEXT=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    62
MODES=""
52056
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
    63
declare -a SYSTEM_OPTIONS=()
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    64
TERMINATE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    65
READONLY=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    66
NOWRITE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    67
59350
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 58846
diff changeset
    68
while getopts "O:P:Se:m:o:qrw" OPT
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    69
do
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    70
  case "$OPT" in
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
    71
    O)
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
    72
      OPTIONS_FILE="$OPTARG"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
    73
      ;;
59350
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 58846
diff changeset
    74
    P)
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 58846
diff changeset
    75
      PROCESS_SOCKET="$OPTARG"
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 58846
diff changeset
    76
      ;;
20923
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    77
    S)
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    78
      SECURE=true
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
    79
      ;;
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    80
    e)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    81
      MLTEXT="$MLTEXT $OPTARG"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    82
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    83
    m)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    84
      if [ -z "$MODES" ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    85
        MODES="\"$OPTARG\""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    86
      else
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    87
        MODES="\"$OPTARG\", $MODES"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    88
      fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    89
      ;;
52056
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
    90
    o)
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
    91
      SYSTEM_OPTIONS["${#SYSTEM_OPTIONS[@]}"]="$OPTARG"
fc458f304f93 added isabelle-process option -o;
wenzelm
parents: 52054
diff changeset
    92
      ;;
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    93
    q)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    94
      TERMINATE=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    95
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    96
    r)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    97
      READONLY=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    98
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
    99
    w)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   100
      NOWRITE=true
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   101
      ;;
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
      usage
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   104
      ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   105
  esac
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   106
done
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   107
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   108
shift $(($OPTIND - 1))
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   109
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   110
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   111
# args
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
INPUT=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   114
OUTPUT=""
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
if [ "$#" -ge 1 ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   117
  INPUT="$1"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   118
  shift
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   119
fi
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
if [ "$#" -ge 1 ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   122
  OUTPUT="$1"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   123
  shift
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   124
fi
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
[ "$#" -ne 0 ] && { echo "Bad args: $*"; 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
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   129
## check ML system
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
[ -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
   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
## input heap file
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
[ -z "$INPUT" ] && INPUT="$ISABELLE_LOGIC"
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
case "$INPUT" in
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   139
  RAW_ML_SYSTEM)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   140
    INFILE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   141
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   142
  */*)
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   143
    INFILE="$INPUT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   144
    [ ! -f "$INFILE" ] && fail "Bad heap file: \"$INFILE\""
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
  *)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   147
    INFILE=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   148
    ISA_PATH=""
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   149
32390
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32322
diff changeset
   150
    splitarray ":" "$ISABELLE_PATH"; PATHS=("${SPLITARRAY[@]}")
32322
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 31797
diff changeset
   151
    for DIR in "${PATHS[@]}"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   152
    do
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   153
      DIR="$DIR/$ML_IDENTIFIER"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   154
      ISA_PATH="$ISA_PATH  $DIR\n"
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   155
      [ -z "$INFILE" -a -f "$DIR/$INPUT" ] && INFILE="$DIR/$INPUT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   156
    done
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   157
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   158
    if [ -z "$INFILE" ]; then
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   159
      echo "Unknown logic \"$INPUT\" -- no heap file found in:" >&2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   160
      echo -ne "$ISA_PATH" >&2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   161
      exit 2
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   162
    fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   163
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   164
esac
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   165
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   166
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   167
## output heap file
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
case "$OUTPUT" in
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   170
  "")
33920
d4d430dfabc6 double check file permissions of write-back image -- more robust for root or administrator on Cygwin;
wenzelm
parents: 32390
diff changeset
   171
    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
   172
      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
   173
    fi
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   174
    ;;
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   175
  */*)
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   176
    OUTFILE="$OUTPUT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   177
    ;;
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
    mkdir -p "$ISABELLE_OUTPUT"
61319
d84b4d39bce1 more explicit umask for important directories: e.g. relevant for Windows 10, where implicit g=rwx leads to odd failure of chmod -w for heap images;
wenzelm
parents: 59350
diff changeset
   180
    chmod $(umask -S) "$ISABELLE_OUTPUT"
27201
e0323036bcf2 removed obsolete ML_SUFFIX;
wenzelm
parents: 25645
diff changeset
   181
    OUTFILE="$ISABELLE_OUTPUT/$OUTPUT"
11550
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
esac
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
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   186
## prepare tmp directory
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
[ -z "$ISABELLE_TMP_PREFIX" ] && ISABELLE_TMP_PREFIX=/tmp/isabelle
16874
wenzelm
parents: 16817
diff changeset
   189
ISABELLE_PID="$$"
17792
4a34fd6884b1 support ML_SUFFIX;
wenzelm
parents: 16874
diff changeset
   190
ISABELLE_TMP="$ISABELLE_TMP_PREFIX$ISABELLE_PID"
16874
wenzelm
parents: 16817
diff changeset
   191
mkdir -p "$ISABELLE_TMP"
61319
d84b4d39bce1 more explicit umask for important directories: e.g. relevant for Windows 10, where implicit g=rwx leads to odd failure of chmod -w for heap images;
wenzelm
parents: 59350
diff changeset
   192
chmod $(umask -S) "$ISABELLE_TMP"
11550
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
## run it!
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
ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-)
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   198
45056
bbd7eac14df3 augment existing print mode;
wenzelm
parents: 45028
diff changeset
   199
[ -n "$MODES" ] && MLTEXT="Unsynchronized.change print_mode (append [$MODES]); $MLTEXT"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   200
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
   201
[ -n "$SECURE" ] && MLTEXT="$MLTEXT; Secure.set_secure ();"
20923
059926d1d074 added option -S (secure mode);
wenzelm
parents: 17792
diff changeset
   202
59350
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 58846
diff changeset
   203
if [ -n "$PROCESS_SOCKET" ]; then
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 58846
diff changeset
   204
  MLTEXT="$MLTEXT; Isabelle_Process.init \"$PROCESS_SOCKET\";"
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
   205
else
51952
4517ceb545c1 re-init ISABELLE_PROCESS_OPTIONS to allow nested ISABELLE_PROCESS invocations, e.g. HOL-Mutabelle-ex;
wenzelm
parents: 51948
diff changeset
   206
  ISABELLE_PROCESS_OPTIONS="$ISABELLE_TMP/options"
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
   207
  if [ -n "$OPTIONS_FILE" ]; then
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
   208
    [ "${#SYSTEM_OPTIONS[@]}" -gt 0 ] && \
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
   209
      fail "Cannot provide options file and options on command-line"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
   210
    mv "$OPTIONS_FILE" "$ISABELLE_PROCESS_OPTIONS" ||
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
   211
      fail "Failed to move options file \"$OPTIONS_FILE\""
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
   212
  else
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
   213
    "$ISABELLE_TOOL" options -x "$ISABELLE_PROCESS_OPTIONS" -- "${SYSTEM_OPTIONS[@]}" || \
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
   214
      fail "Failed to retrieve Isabelle system options"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 56628
diff changeset
   215
  fi
51964
f1c1d8637216 clean startup of RAW session;
wenzelm
parents: 51952
diff changeset
   216
  if [ "$INPUT" != RAW_ML_SYSTEM -a "$INPUT" != RAW ]; then
56628
a2df9de46060 tuned -- avoid warning about catch-all handler;
wenzelm
parents: 56439
diff changeset
   217
    MLTEXT="Exn.capture_exit 2 Options.load_default (); $MLTEXT"
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
   218
  fi
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   219
fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   220
48698
2585042b1a30 pass Isabelle/Scala system options into ML process of Isar tty or build jobs;
wenzelm
parents: 45056
diff changeset
   221
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
   222
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   223
if [ -f "$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM" ]; then
58846
98c03412079b discontinued Isar TTY loop;
wenzelm
parents: 58842
diff changeset
   224
  "$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   225
else
58846
98c03412079b discontinued Isar TTY loop;
wenzelm
parents: 58842
diff changeset
   226
  "$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   227
fi
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   228
RC="$?"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   229
48698
2585042b1a30 pass Isabelle/Scala system options into ML process of Isar tty or build jobs;
wenzelm
parents: 45056
diff changeset
   230
[ -n "$ISABELLE_PROCESS_OPTIONS" ] && rm -f "$ISABELLE_PROCESS_OPTIONS"
11550
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   231
rmdir "$ISABELLE_TMP"
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   232
915c5de6480f smart selection of isabelle-process versus isabelle-interface;
wenzelm
parents:
diff changeset
   233
exit "$RC"