which/which2.sh

17 lines
363 B
Bash
Raw Normal View History

# Initialization script for bash, sh, mksh and ksh
2021-03-21 13:17:16 +00:00
_declare="declare -f"
_opt="-f"
if [ "$0" = "ksh" ] || [ "$0" = "-ksh" ] || [ "$0" = "mksh" ] || [ "$0" = "-mksh" ] ; then
_declare="typeset -f"
_opt=""
fi
which ()
{
2021-03-21 13:17:16 +00:00
(alias; eval ${_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
2021-03-21 13:17:16 +00:00
export ${_opt} which