#!/bin/bash

# IsSymbolicLinkInPath.bash
# Fri Mar 22 13:28:05 PDT 2013
# Chieh Cheng
# http://www.CynosureX.com/

# GNU General Public License (GPL) Version 2, June 1991

  scriptDir=`dirname "$0"`
  scriptName=`basename "$0"`

function check ()
{
  arg="$1"
  result=0

  # dirname will end up with "/" or "." depending on absolute or relative path.
  while [ "${arg}" != "/" ] && [ "${arg}" != "." ] && [ ${result} -eq 0 ]
  do
    if [ -L "${arg}" ]
    then
      result=1
    fi

    arg=`dirname "${arg}"`
  done

  echo ${result}
}

function usage ()
{
  echo "  Usage:   \"${scriptName}\" \"path\""
}

  if [ $# -eq 1 ]
  then
    arg="$1"
    check "${arg}"
  else
    usage
  fi
