bin/isabelle
author wenzelm
Wed, 28 Dec 2011 13:00:51 +0100
changeset 46003 c0fe5e8e4864
parent 42124 7519c7c33017
child 48858 86816c61b5ca
permissions -rwxr-xr-x
print case syntax depending on "show_cases" configuration option;

#!/usr/bin/env bash
#
# Author: Markus Wenzel, TU Muenchen
#
# Isabelle tool wrapper.

if [ -L "$0" ]; then
  TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
  exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
fi


## settings

PRG="$(basename "$0")"

ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2


## diagnostics

function usage()
{
  echo
  echo "Usage: $PRG NAME [ARGS ...]"
  echo
  echo "  Start Isabelle tool NAME with ARGS; pass \"-?\" for tool specific help."
  echo
  echo "  Available tools are:"
  perl -w "$ISABELLE_HOME/lib/scripts/tools.pl"
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}


## args

[ "$#" -lt 1 -o "$1" = "-?" ] && usage

TOOLNAME="$1"
shift


## main

splitarray ":" "$ISABELLE_TOOLS"; TOOLS=("${SPLITARRAY[@]}")

for DIR in "${TOOLS[@]}"
do
  TOOL="$DIR/$TOOLNAME"
  case "$TOOL" in
    *~ | *.orig) ;;
    *) [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@" ;;
  esac
done

fail "Unknown Isabelle tool: $TOOLNAME"