Skip to content

Instantly share code, notes, and snippets.

@rawiriblundell
Created June 10, 2021 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rawiriblundell/eb29d0e147996a51e92a5737a9ba57ce to your computer and use it in GitHub Desktop.
Save rawiriblundell/eb29d0e147996a51e92a5737a9ba57ce to your computer and use it in GitHub Desktop.
# A portable alternative to exists/get_command/which/type
pathfind() {
OLDIFS="${IFS}"
IFS=:
for prog in ${PATH}; do
if [[ -x "${prog}/$*" ]]; then
printf -- '%s\n' "${prog}/$*"
IFS="${OLDIFS}"
return 0
fi
done
IFS="${OLDIFS}"
return 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment