#!/bin/sh

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

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

LLDBINIT_PATH="$HOME/.lldbinit"

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

exit 1


