#!/bin/sh
# acquire a path to a program somehow
if [ "x$BASH" != x ]; then
    function pathto {
	type -p "$1"
    }
elif (command -v echo) >/dev/null 2>&1 &&
     command -v echo | grep / >/dev/null; then
    function pathto {
	command -v "$1"
    }
elif (whence -p echo) >/dev/null 2>&1 &&
     whence -p echo | grep / >/dev/null; then
    function pathto {
	whence -p "$1"
    }
else
    function pathto {
	# iffy...
	type "$1" | sed -e 's/^[^ ][^ ]* is hashed (\(.*\))$/\1/' \
			-e "s/^\\([^ ][^ ]*\\) is [^/]*\$/'\\1'/" \
			-e 's/^[^ ][^ ]* is //'
    }
fi

res=`pathto $1`
if [ "x$res" = "x" ]
then
  echo "You do not have \`$1' installed on your system"
  exit 1
else
  echo "$res"
fi
