bin/isabelle
changeset 28504 7ad7d7d6df47
parent 15967 f9163c6f69d6
child 28506 3ab515ee4e6f
equal deleted inserted replaced
28503:a30b7169fdd1 28504:7ad7d7d6df47
     1 #!/usr/bin/env bash
     1 #!/usr/bin/env bash
     2 #
     2 #
     3 # $Id$
     3 # $Id$
     4 # Author: Markus Wenzel, TU Muenchen
     4 # Author: Markus Wenzel, TU Muenchen
     5 #
     5 #
     6 # Smart selection of isabelle-process versus isabelle-interface.
     6 # Isabelle tool wrapper.
     7 
     7 
     8 if [ -L "$0" ]; then
     8 if [ -L "$0" ]; then
     9   TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
     9   TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
    10   exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
    10   exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
    11 fi
    11 fi
    12 
    12 
    13 THIS=$(cd "$(dirname "$0")"; pwd -P)
       
    14 NAME="$(basename "$0")"
       
    15 
    13 
    16 case "$NAME" in
    14 ## settings
    17   I*)
       
    18     PRG=isabelle-interface
       
    19     ;;
       
    20   i*)
       
    21     PRG=isabelle-process
       
    22     ;;
       
    23 esac
       
    24 
    15 
    25 exec "$THIS/$PRG" "$@"
    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"