Created
June 10, 2021 20:05
-
-
Save rawiriblundell/eb29d0e147996a51e92a5737a9ba57ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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