Last active
June 4, 2022 00:43
-
-
Save Trucido/6315513d3cb1ac0a30826550761540d2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
which2() { | |
[ -t 1 ] && { | |
case "${BASH##*/}${ZSH_NAME}" in | |
(bash) { | |
{ [ "`builtin type -t $1 2>/dev/null`" = "builtin" ] >&/dev/null; } && \ | |
{ printf '%s is a shell builtin\n' "$1"; return; } | |
} | |
{ | |
{ (alias;typeset -f) | \which --tty-only --read-alias --read-functions --show-tilde "$@" >&/dev/null; } && \ | |
{ (alias;typeset -f) | \which --tty-only --read-alias --read-functions --show-tilde "$@" && return $?; } | |
} | |
{ | |
{ builtin type -a "$@" >&/dev/null; } && \ | |
{ builtin type -a "$@" && return $?; } | |
} ;; | |
(zsh) { | |
{ [ "`builtin whence -w $1`" = "$1: builtin" ] >&/dev/null; } && \ | |
{ printf '%s is a shell builtin\n' "$1"; return; } | |
} | |
{ | |
{ builtin which "$@" >&/dev/null; } && \ | |
{ builtin which "$@" && return $?; } | |
} | |
{ | |
{ builtin type -a "$@" >&/dev/null; } && \ | |
{ builtin type -a "$@" && return $?; } | |
} ;; | |
esac; } | |
command -p which "$@"; return $? || return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment