#!/bin/sh

SCRIPT_DIR=$(dirname "$0")
SCRIPT=$"Diff Unsaved Changes in Kaleidoscope.sh"
APP_SUPPORT=$"$HOME/Library/Application Support/BBEdit/Scripts"
TOOL_ENDPATH="$APP_SUPPORT/$SCRIPT"
TOOL_PATH="$TOOL_ENDPATH"
TOOL_SRCPATH="$SCRIPT_DIR/$SCRIPT"

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

 INSTALL_VERSION=$(sed -n "s/# Build \([0-9]\)/\1/p" "$TOOL_PATH")
 CURRENT_VERSION=$(sed -n "s/# Build \([0-9]\)/\1/p" "$TOOL_SRCPATH")

 echo "Installed: $INSTALL_VERSION"
 echo "Current: $CURRENT_VERSION"

# echo "$INSTALL_VERSION"

if [ $CURRENT_VERSION \> $INSTALL_VERSION ] ; then
  exit 210
else
  exit 0
fi
