#!/bin/sh

SCRIPT_DIR=$(dirname "$0")
TOOL_FILENAME="pdb_ksdiff.py"
TOOL_ENDPATH="/Library/Application Support/Kaleidoscope/$TOOL_FILENAME"
TOOL_PATH="$HOME$TOOL_ENDPATH"
TOOL_SRCPATH="$SCRIPT_DIR/$TOOL_FILENAME"

if [ -r "$TOOL_SRCPATH" ] ; then
#  echo "Source found $TOOL_SRCPATH"
  :
else
  echo "Could not read source $TOOL_SRCPATH" >&2
  exit 1
fi

if [ -r "$TOOL_PATH" ] ; then
#  echo "Could read target $TOOL_PATH"
  :
else
  echo "Could not read target $TOOL_PATH" >&2
  exit 1
fi

PDBRC_PATH="$HOME/.pdbrc"

if [ -r "$PDBRC_PATH" ] ; then
  grep "$TOOL_ENDPATH" "$PDBRC_PATH" >/dev/null && exit 0
else
  echo "Could not read .pdbrc $PDBRC_PATH" >&2
fi

exit 1


