set -eu
# explicitly reset the IFS for the old dash (ash)
IFS=$(printf '\n\t') && IFS=" ${IFS#?}${IFS%?}"
exists() {
  case "$1" in
    */*) [ -x "$1" ] && return 0 ;;
    *)
      set -- "$1" "${PATH:-}:"
      while [ -n "$2" ]; do
        set -- "$1" "${2#*:}" "${2%%:*}"
        if [ -f "${3:-./}/$1" ] && [ -x "${3:-./}/$1" ]; then
          return 0
        fi
      done
      ;;
  esac
  return 1
}
