lib/Tools/console
author wenzelm
Mon, 30 Jun 2014 09:43:44 +0200
changeset 57439 0e41f26a0250
parent 52062 lib/Tools/tty@4f91262e7f33
child 57580 86b413b8f779
permissions -rwxr-xr-x
"isabelle tty" is superseded by "isabelle console";
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=()
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    34
declare -a BUILD_OPTIONS=()
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    35
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    36
LOGIC="$ISABELLE_LOGIC"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    37
DO_BUILD="true"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    38
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    39
while getopts "d:l:m:no:s" OPT
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    40
do
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    41
  case "$OPT" in
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    42
    d)
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    43
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="-d"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    44
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    45
      ;;
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    46
    l)
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    47
      LOGIC="$OPTARG"
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    48
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    49
    m)
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    50
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="-m"
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    51
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="$OPTARG"
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    52
      ;;
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    53
    n)
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    54
      DO_BUILD="false"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    55
      ;;
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    56
    o)
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    57
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="-o"
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    58
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="$OPTARG"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    59
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="-o"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    60
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    61
      ;;
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    62
    s)
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    63
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="-s"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    64
      ;;
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
      usage
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    67
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    68
  esac
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    69
done
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
shift $(($OPTIND - 1))
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    72
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
# args
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
[ "$#" -ne 0 ] && { echo "Bad args: $*"; usage; }
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    77
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    78
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    79
## main
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    80
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    81
if [ "$DO_BUILD" = true ]
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    82
then
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    83
  "$ISABELLE_TOOL" build -b -n "${BUILD_OPTIONS[@]}" "$LOGIC" >/dev/null 2>/dev/null ||
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    84
  {
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    85
    echo "Build started for Isabelle/$LOGIC"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    86
    "$ISABELLE_TOOL" build -b "${BUILD_OPTIONS[@]}" "$LOGIC" || exit "$?"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    87
  }
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    88
fi
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    89
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    90
if type -p "$ISABELLE_LINE_EDITOR" > /dev/null
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    91
then
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    92
  exec "$ISABELLE_LINE_EDITOR" "$ISABELLE_PROCESS" "${ISABELLE_OPTIONS[@]}" -- "$LOGIC"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    93
else
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    94
  echo "### No line editor: \"$ISABELLE_LINE_EDITOR\""
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    95
  exec "$ISABELLE_PROCESS" "${ISABELLE_OPTIONS[@]}" -- "$LOGIC"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    96
fi