#!/bin/sh

if test ! "${CMT_WHICH}" = "" ; then
  echo ${CMT_WHICH}
  exit 0
fi

which cat 1>/dev/null 2>/dev/null
yes="$?"
which abcdefghijklmnopqrstuvwxyz 1>/dev/null 2>/dev/null
no="$?"
if test "${yes}" = 0 -a "${no}" = 0 ; then
  type cat 1>/dev/null 2>/dev/null
  yes="$?"
  type abcdefghijklmnopqrstuvwxyz 1>/dev/null 2>/dev/null
  no="$?"
  if test "${yes}" = 0 -a "${no}" = 0 ; then
    /usr/bin/type cat 1>/dev/null 2>/dev/null
    yes="$?"
    /usr/bin/type abcdefghijklmnopqrstuvwxyz 1>/dev/null 2>/dev/null
    no="$?"
    if test "${yes}" = 0 -a "${no}" = 0 ; then
      exit 1
    else
      echo "/usr/bin/type"
    fi
  else
    echo "type"
  fi
else
  echo "which"
fi

exit 0
