bin/isabelle
author blanchet
Mon, 23 Jul 2012 15:32:30 +0200
changeset 49449 aaaec69db3db
parent 42995 7519c7c33017
child 49873 86816c61b5ca
permissions -rwxr-xr-x
ensure all calls to "mash" program are synchronous
     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   perl -w "$ISABELLE_HOME/lib/scripts/tools.pl"
    32   exit 1
    33 }
    34 
    35 function fail()
    36 {
    37   echo "$1" >&2
    38   exit 2
    39 }
    40 
    41 
    42 ## args
    43 
    44 [ "$#" -lt 1 -o "$1" = "-?" ] && usage
    45 
    46 TOOLNAME="$1"
    47 shift
    48 
    49 
    50 ## main
    51 
    52 splitarray ":" "$ISABELLE_TOOLS"; TOOLS=("${SPLITARRAY[@]}")
    53 
    54 for DIR in "${TOOLS[@]}"
    55 do
    56   TOOL="$DIR/$TOOLNAME"
    57   case "$TOOL" in
    58     *~ | *.orig) ;;
    59     *) [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@" ;;
    60   esac
    61 done
    62 
    63 fail "Unknown Isabelle tool: $TOOLNAME"