bin/isabelle
author blanchet
Mon, 04 Oct 2010 09:08:46 +0200
changeset 39931 97b8051033be
parent 33915 44a10fe6bd10
child 42077 96c50a4210a2
permissions -rwxr-xr-x
renamed internal function
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10555
2323ec838401 /usr/bin/env bash;
wenzelm
parents: 10511
diff changeset
     1
#!/usr/bin/env bash
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
     2
#
9786
wenzelm
parents: 8359
diff changeset
     3
# Author: Markus Wenzel, TU Muenchen
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
     4
#
28504
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
     5
# Isabelle tool wrapper.
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
     6
15843
d5bd4a18ce70 improved handling of symlinks;
wenzelm
parents: 15784
diff changeset
     7
if [ -L "$0" ]; then
d5bd4a18ce70 improved handling of symlinks;
wenzelm
parents: 15784
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: 15784
diff changeset
    10
fi
d5bd4a18ce70 improved handling of symlinks;
wenzelm
parents: 15784
diff changeset
    11
28504
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    12
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    13
## settings
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    14
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    15
PRG="$(basename "$0")"
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    16
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    17
ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    18
source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    19
32390
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32322
diff changeset
    20
splitarray ":" "$ISABELLE_TOOLS"; TOOLS=("${SPLITARRAY[@]}")
32322
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    21
28504
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    22
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    23
## diagnostics
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    24
28504
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    25
function usage()
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    26
{
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    27
  echo
28506
3ab515ee4e6f tuned isabelle usage;
wenzelm
parents: 28504
diff changeset
    28
  echo "Usage: $PRG NAME [ARGS ...]"
28504
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    29
  echo
28506
3ab515ee4e6f tuned isabelle usage;
wenzelm
parents: 28504
diff changeset
    30
  echo "  Start Isabelle tool NAME with ARGS; pass \"-?\" for tool specific help."
28504
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    31
  echo
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    32
  echo "  Available tools are:"
33915
44a10fe6bd10 proper quoting of array expansion -- allow spaces in components;
wenzelm
parents: 32390
diff changeset
    33
  for DIR in "${TOOLS[@]}"
32322
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    34
  do
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    35
    if [ -d "$DIR" ]; then
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    36
      for TOOL in "$DIR"/*
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    37
      do
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    38
        if [ -f "$TOOL" -a -x "$TOOL" ]; then
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    39
          NAME="$(basename "$TOOL")"
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    40
          DESCRLINE="$(fgrep DESCRIPTION: "$TOOL" | sed -e 's/^.*DESCRIPTION: *//')"
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    41
          echo "    $NAME - $DESCRLINE"
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    42
        fi
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    43
      done
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    44
    fi
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    45
  done
28504
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    46
  exit 1
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    47
}
9786
wenzelm
parents: 8359
diff changeset
    48
28504
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    49
function fail()
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    50
{
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    51
  echo "$1" >&2
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    52
  exit 2
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    53
}
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    54
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    55
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    56
## args
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    57
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    58
[ "$#" -lt 1 -o "$1" = "-?" ] && usage
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    59
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    60
TOOLNAME="$1"
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    61
shift
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    62
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    63
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    64
## main
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    65
32322
45cb4a86eca2 change IFS only locally -- thanks to bash arrays;
wenzelm
parents: 28934
diff changeset
    66
for DIR in "${TOOLS[@]}"
28504
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    67
do
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    68
  TOOL="$DIR/$TOOLNAME"
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    69
  [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@"
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    70
done
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    71
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 15967
diff changeset
    72
fail "Unknown Isabelle tool: $TOOLNAME"