bin/isatool
author kleing
Mon Jun 21 10:25:57 2004 +0200 (2004-06-21)
changeset 14981 e73f8140af78
parent 11044 5873a05b4d21
child 15843 d5bd4a18ce70
permissions -rwxr-xr-x
Merged in license change from Isabelle2004
     1 #!/usr/bin/env bash
     2 #
     3 # $Id$
     4 # Author: Markus Wenzel, TU Muenchen
     5 #
     6 # Isabelle tool starter -- provides settings environment
     7 # and keeps your PATH name space clean.
     8 
     9 
    10 ## settings
    11 
    12 PRG="$(basename "$0")"
    13 
    14 ISABELLE_HOME="$(dirname "$0")/.."
    15 . "$ISABELLE_HOME/lib/scripts/getsettings" || \
    16   { echo "$PRG probably not called from its original place!"; exit 2; }
    17 
    18 
    19 ## diagnostics
    20 
    21 function usage()
    22 {
    23   echo
    24   echo "Usage: $PRG TOOL [ARGS ...]"
    25   echo
    26   echo "  Start Isabelle utility program TOOL with ARGS. Pass \"-?\" to TOOL"
    27   echo "  for more specific help."
    28   echo
    29   echo "  Available tools are:"
    30   (
    31     ORIG_IFS="$IFS"
    32     IFS=":"
    33     for DIR in $ISABELLE_TOOLS
    34     do
    35       cd "$DIR"
    36       echo
    37       for T in *
    38       do
    39         if [ -f "$T" -a -x "$T" ]; then
    40           DESCRLINE=$(fgrep DESCRIPTION: "$T" | sed -e 's/^.*DESCRIPTION: *//')
    41           echo "    $T - $DESCRLINE"
    42         fi
    43       done
    44     done
    45     IFS="$ORIG_IFS"
    46   )
    47   echo
    48   exit 1
    49 }
    50 
    51 function fail()
    52 {
    53   echo "$1" >&2
    54   exit 2
    55 }
    56 
    57 
    58 ## args
    59 
    60 [ "$#" -lt 1 -o "$1" = "-?" ] && usage
    61 
    62 TOOLNAME="$1"
    63 shift
    64 
    65 
    66 ## main
    67 
    68 ORIG_IFS="$IFS"
    69 IFS=":"
    70 for DIR in $ISABELLE_TOOLS
    71 do
    72   TOOL="$DIR/$TOOLNAME"
    73   [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@"
    74 done
    75 IFS="$ORIG_IFS"
    76 
    77 fail "Unknown Isabelle tool: $TOOLNAME"