lib/Tools/console
author wenzelm
Mon, 18 Aug 2014 12:17:31 +0200
changeset 57978 8f4a332500e4
parent 57686 5b16e2370ccb
child 61135 8f7d802b7a71
permissions -rwxr-xr-x
Added tag Isabelle2014-RC4 for changeset 113b43b84412
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     2
#
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
     3
# Author: Makarius
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     4
#
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
     5
# DESCRIPTION: run Isabelle process with raw ML console and line editor
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     6
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     7
PRG="$(basename "$0")"
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     8
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     9
function usage()
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    10
{
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    11
  echo
28650
a7ba12e0d3b7 tuned usage line;
wenzelm
parents: 28502
diff changeset
    12
  echo "Usage: isabelle $PRG [OPTIONS]"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    13
  echo
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    14
  echo "  Options are:"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    15
  echo "    -d DIR       include session directory"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    16
  echo "    -l NAME      logic session name (default ISABELLE_LOGIC=\"$ISABELLE_LOGIC\")"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    17
  echo "    -m MODE      add print mode for output"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    18
  echo "    -n           no build of session image on startup"
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    19
  echo "    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    20
  echo "    -s           system build mode for session image"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    21
  echo
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    22
  echo "  Run Isabelle process with raw ML console and line editor"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    23
  echo "  (ISABELLE_LINE_EDITOR=\"$ISABELLE_LINE_EDITOR\")."
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    24
  echo
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    25
  exit 1
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    26
}
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    27
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    28
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    29
## process command line
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    30
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    31
# options
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    32
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    33
declare -a ISABELLE_OPTIONS=()
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    34
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    35
declare -a INCLUDE_DIRS=()
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    36
LOGIC="$ISABELLE_LOGIC"
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    37
NO_BUILD="false"
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    38
declare -a SYSTEM_OPTIONS=()
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    39
SYSTEM_MODE="false"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    40
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    41
while getopts "d:l:m:no:s" OPT
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    42
do
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    43
  case "$OPT" in
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    44
    d)
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    45
      INCLUDE_DIRS["${#INCLUDE_DIRS[@]}"]="$OPTARG"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    46
      ;;
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    47
    l)
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    48
      LOGIC="$OPTARG"
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    49
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    50
    m)
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    51
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="-m"
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    52
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="$OPTARG"
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    53
      ;;
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    54
    n)
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    55
      NO_BUILD="true"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    56
      ;;
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    57
    o)
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    58
      SYSTEM_OPTIONS["${#SYSTEM_OPTIONS[@]}"]="$OPTARG"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    59
      ;;
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    60
    s)
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    61
      SYSTEM_MODE="true"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    62
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    63
    \?)
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    64
      usage
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    65
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    66
  esac
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    67
done
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    68
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    69
shift $(($OPTIND - 1))
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    70
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    71
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    72
# args
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    73
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    74
[ "$#" -ne 0 ] && { echo "Bad args: $*"; usage; }
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    75
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    76
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    77
## main
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    78
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    79
isabelle_admin_build jars || exit $?
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    80
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    81
declare -a JAVA_ARGS; eval "JAVA_ARGS=($ISABELLE_BUILD_JAVA_OPTIONS)"
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    82
57686
5b16e2370ccb proper mkdir;
wenzelm
parents: 57581
diff changeset
    83
mkdir -p "$ISABELLE_TMP_PREFIX" || exit $?
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    84
OPTIONS_FILE="$ISABELLE_TMP_PREFIX/options$$"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    85
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    86
"$ISABELLE_TOOL" java "${JAVA_ARGS[@]}" isabelle.Build_Console \
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    87
  "$LOGIC" "$NO_BUILD" "$SYSTEM_MODE" "$OPTIONS_FILE" \
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    88
  "${INCLUDE_DIRS[@]}" $'\n' "${SYSTEM_OPTIONS[@]}" || {
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    89
  rm -f "$OPTIONS_FILE"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    90
  exit "$?"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    91
}
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    92
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    93
ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="-O"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    94
ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="$OPTIONS_FILE"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    95
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    96
if type -p "$ISABELLE_LINE_EDITOR" > /dev/null
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    97
then
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    98
  exec "$ISABELLE_LINE_EDITOR" "$ISABELLE_PROCESS" "${ISABELLE_OPTIONS[@]}" -- "$LOGIC"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    99
else
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
   100
  echo "### No line editor: \"$ISABELLE_LINE_EDITOR\""
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
   101
  exec "$ISABELLE_PROCESS" "${ISABELLE_OPTIONS[@]}" -- "$LOGIC"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
   102
fi