#!/bin/sh

eval "last=\${$#}"

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

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