which/which2.sh

18 lines
383 B
Bash

# Initialization script for bash, sh, mksh and ksh
_declare="declare -f"
_opt="-f"
_shell="$(basename $SHELL)"
if [ "$_shell" = "ksh" ] || [ "$_shell" = "mksh" ] || [ "$_shell" = "zsh" ] ; then
_declare="typeset -f"
_opt=""
fi
which ()
{
(alias; eval ${_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
export ${_opt} which