bin/isabelle
changeset 28504 7ad7d7d6df47
parent 15967 f9163c6f69d6
child 28506 3ab515ee4e6f
     1.1 --- a/bin/isabelle	Sat Oct 04 16:19:49 2008 +0200
     1.2 +++ b/bin/isabelle	Sat Oct 04 17:40:56 2008 +0200
     1.3 @@ -3,23 +3,76 @@
     1.4  # $Id$
     1.5  # Author: Markus Wenzel, TU Muenchen
     1.6  #
     1.7 -# Smart selection of isabelle-process versus isabelle-interface.
     1.8 +# Isabelle tool wrapper.
     1.9  
    1.10  if [ -L "$0" ]; then
    1.11    TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
    1.12    exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
    1.13  fi
    1.14  
    1.15 -THIS=$(cd "$(dirname "$0")"; pwd -P)
    1.16 -NAME="$(basename "$0")"
    1.17 +
    1.18 +## settings
    1.19 +
    1.20 +PRG="$(basename "$0")"
    1.21 +
    1.22 +ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
    1.23 +source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2
    1.24 +
    1.25 +
    1.26 +## diagnostics
    1.27  
    1.28 -case "$NAME" in
    1.29 -  I*)
    1.30 -    PRG=isabelle-interface
    1.31 -    ;;
    1.32 -  i*)
    1.33 -    PRG=isabelle-process
    1.34 -    ;;
    1.35 -esac
    1.36 +function usage()
    1.37 +{
    1.38 +  echo
    1.39 +  echo "Usage: $PRG TOOL [ARGS ...]"
    1.40 +  echo
    1.41 +  echo "  Start Isabelle utility program TOOL with ARGS. Pass \"-?\" to TOOL"
    1.42 +  echo "  for more specific help."
    1.43 +  echo
    1.44 +  echo "  Available tools are:"
    1.45 +  (
    1.46 +    ORIG_IFS="$IFS"
    1.47 +    IFS=":"
    1.48 +    for DIR in $ISABELLE_TOOLS
    1.49 +    do
    1.50 +      cd "$DIR"
    1.51 +      for T in *
    1.52 +      do
    1.53 +        if [ -f "$T" -a -x "$T" ]; then
    1.54 +          DESCRLINE=$(fgrep DESCRIPTION: "$T" | sed -e 's/^.*DESCRIPTION: *//')
    1.55 +          echo "    $T - $DESCRLINE"
    1.56 +        fi
    1.57 +      done
    1.58 +    done
    1.59 +    IFS="$ORIG_IFS"
    1.60 +  )
    1.61 +  exit 1
    1.62 +}
    1.63  
    1.64 -exec "$THIS/$PRG" "$@"
    1.65 +function fail()
    1.66 +{
    1.67 +  echo "$1" >&2
    1.68 +  exit 2
    1.69 +}
    1.70 +
    1.71 +
    1.72 +## args
    1.73 +
    1.74 +[ "$#" -lt 1 -o "$1" = "-?" ] && usage
    1.75 +
    1.76 +TOOLNAME="$1"
    1.77 +shift
    1.78 +
    1.79 +
    1.80 +## main
    1.81 +
    1.82 +ORIG_IFS="$IFS"
    1.83 +IFS=":"
    1.84 +for DIR in $ISABELLE_TOOLS
    1.85 +do
    1.86 +  TOOL="$DIR/$TOOLNAME"
    1.87 +  [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@"
    1.88 +done
    1.89 +IFS="$ORIG_IFS"
    1.90 +
    1.91 +fail "Unknown Isabelle tool: $TOOLNAME"