# get the path of the given program
# `which` is not portable and `type` has no well-formed output format

installed_path() {
  test -z "$1" && return 1

  # keep IFS change local
  (
    IFS=:
    # walk PATH
    for directory in ${PATH}; do
      if test -x "${directory}/$1"; then
        printf '%s\n' "${directory}/$1"
        return 0
      fi
    done

    return 1
  )
}
