#!/bin/sh

eval "last=\${$#}"

p=`expr "$last" : '[a-zA-Z][a-zA-Z]*:\(.*\)'`
if [ "$p" != "" ]; then
  exec mv.pike "$@"

else
  OLDIFS="$IFS"
  IFS=:
  for path in $PATH; do
    if [ -x "$path/mv" ]; then
      if [ "$first" = "" ]; then
	first="$path"
      elif [ "$path" != "$first" ]; then
	next="$path/mv"
	break
      fi
    fi
  done
  IFS="$OLDIFS"

  if [ -f "${1}.exe" ]; then
    if [ -d "$last" ]; then
      exec "$next" "${1}.exe" "${last}"
    else
      exec "$next" "${1}.exe" "${last}.exe"
    fi
  else
    exec "$next" "$@"
  fi
fi
