bin/isatool
author ballarin
Tue Jun 20 15:53:44 2006 +0200 (2006-06-20)
changeset 19931 fb32b43e7f80
parent 15967 f9163c6f69d6
permissions -rwxr-xr-x
Restructured locales with predicates: import is now an interpretation.
New method intro_locales.
     1 #!/usr/bin/env bash
     2 #
     3 # $Id$
     4 # Author: Markus Wenzel, TU Muenchen
     5 #
     6 # Isabelle tool starter.
     7 
     8 if [ -L "$0" ]; then
     9   TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
    10   exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
    11 fi
    12 
    13 
    14 ## settings
    15 
    16 PRG="$(basename "$0")"
    17 
    18 ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
    19 source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2
    20 
    21 
    22 ## diagnostics
    23 
    24 function usage()
    25 {
    26   echo
    27   echo "Usage: $PRG TOOL [ARGS ...]"
    28   echo
    29   echo "  Start Isabelle utility program TOOL with ARGS. Pass \"-?\" to TOOL"
    30   echo "  for more specific help."
    31   echo
    32   echo "  Available tools are:"
    33   (
    34     ORIG_IFS="$IFS"
    35     IFS=":"
    36     for DIR in $ISABELLE_TOOLS
    37     do
    38       cd "$DIR"
    39       for T in *
    40       do
    41         if [ -f "$T" -a -x "$T" ]; then
    42           DESCRLINE=$(fgrep DESCRIPTION: "$T" | sed -e 's/^.*DESCRIPTION: *//')
    43           echo "    $T - $DESCRLINE"
    44         fi
    45       done
    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"