#!/usr/bin/env bash
#
# $Id: isabelle-interface,v 1.8 2005/05/17 16:10:33 wenzelm Exp $
# Author: Markus Wenzel, TU Muenchen
#
# Isabelle interface startup script.

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 fail()
{
  echo "$1" >&2
  exit 2
}


## main

case "$ISABELLE_INTERFACE" in
  none)
    INTERFACE="$ISABELLE"
    ;;
  */*)
    INTERFACE="$ISABELLE_INTERFACE"
    ;;
esac

[ ! -x "$INTERFACE" ] && fail "Bad Isabelle interface: \"$ISABELLE_INTERFACE\""

exec "$INTERFACE" "$@"
