#!/bin/bash

eval "last=\${$#}"

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

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

  exec "$next" "$@"
fi
