bin/isabelle
author Walther Neuper <neuper@ist.tugraz.at>
Thu, 09 Sep 2010 13:39:30 +0200
branchisac-update-Isa09-2
changeset 38000 067d4e3ac358
parent 33931 44a10fe6bd10
child 37955 5305daa4228e
child 42948 96c50a4210a2
permissions -rwxr-xr-x
updated Knowledge/AlgEin.thy
     1 #!/usr/bin/env bash
     2 #
     3 # Author: Markus Wenzel, TU Muenchen
     4 #
     5 # Isabelle tool wrapper.
     6 
     7 if [ -L "$0" ]; then
     8   TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
     9   exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
    10 fi
    11 
    12 
    13 ## settings
    14 
    15 PRG="$(basename "$0")"
    16 
    17 ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
    18 source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2
    19 
    20 splitarray ":" "$ISABELLE_TOOLS"; TOOLS=("${SPLITARRAY[@]}")
    21 
    22 
    23 ## diagnostics
    24 
    25 function usage()
    26 {
    27   echo
    28   echo "Usage: $PRG NAME [ARGS ...]"
    29   echo
    30   echo "  Start Isabelle tool NAME with ARGS; pass \"-?\" for tool specific help."
    31   echo
    32   echo "  Available tools are:"
    33   for DIR in "${TOOLS[@]}"
    34   do
    35     if [ -d "$DIR" ]; then
    36       for TOOL in "$DIR"/*
    37       do
    38         if [ -f "$TOOL" -a -x "$TOOL" ]; then
    39           NAME="$(basename "$TOOL")"
    40           DESCRLINE="$(fgrep DESCRIPTION: "$TOOL" | sed -e 's/^.*DESCRIPTION: *//')"
    41           echo "    $NAME - $DESCRLINE"
    42         fi
    43       done
    44     fi
    45   done
    46   exit 1
    47 }
    48 
    49 function fail()
    50 {
    51   echo "$1" >&2
    52   exit 2
    53 }
    54 
    55 
    56 ## args
    57 
    58 [ "$#" -lt 1 -o "$1" = "-?" ] && usage
    59 
    60 TOOLNAME="$1"
    61 shift
    62 
    63 
    64 ## main
    65 
    66 for DIR in "${TOOLS[@]}"
    67 do
    68   TOOL="$DIR/$TOOLNAME"
    69   [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@"
    70 done
    71 
    72 fail "Unknown Isabelle tool: $TOOLNAME"