bin/isabelle
author wenzelm
Mon Dec 01 17:48:12 2008 +0100 (2008-12-01)
changeset 28934 801098c96f59
parent 28506 3ab515ee4e6f
child 32322 45cb4a86eca2
permissions -rwxr-xr-x
proper check of ISABELLE_TOOLS directories;
     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 
    21 ## diagnostics
    22 
    23 function usage()
    24 {
    25   echo
    26   echo "Usage: $PRG NAME [ARGS ...]"
    27   echo
    28   echo "  Start Isabelle tool NAME with ARGS; pass \"-?\" for tool specific help."
    29   echo
    30   echo "  Available tools are:"
    31   (
    32     ORIG_IFS="$IFS"
    33     IFS=":"
    34     for DIR in $ISABELLE_TOOLS
    35     do
    36       if [ -d "$DIR" ]; then
    37         cd "$DIR"
    38         for T in *
    39         do
    40           if [ -f "$T" -a -x "$T" ]; then
    41             DESCRLINE=$(fgrep DESCRIPTION: "$T" | sed -e 's/^.*DESCRIPTION: *//')
    42             echo "    $T - $DESCRLINE"
    43           fi
    44         done
    45       fi
    46     done
    47     IFS="$ORIG_IFS"
    48   )
    49   exit 1
    50 }
    51 
    52 function fail()
    53 {
    54   echo "$1" >&2
    55   exit 2
    56 }
    57 
    58 
    59 ## args
    60 
    61 [ "$#" -lt 1 -o "$1" = "-?" ] && usage
    62 
    63 TOOLNAME="$1"
    64 shift
    65 
    66 
    67 ## main
    68 
    69 ORIG_IFS="$IFS"
    70 IFS=":"
    71 for DIR in $ISABELLE_TOOLS
    72 do
    73   TOOL="$DIR/$TOOLNAME"
    74   [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@"
    75 done
    76 IFS="$ORIG_IFS"
    77 
    78 fail "Unknown Isabelle tool: $TOOLNAME"