which/which2.sh

19 lines
405 B
Bash
Raw Normal View History

# shellcheck shell=sh
# Initialization script for bash, sh, mksh and ksh
2021-03-21 13:17:16 +00:00
_declare="declare -f"
_opt="-f"
2021-03-23 18:57:58 +00:00
_shell="$(basename $SHELL)"
2021-03-21 13:17:16 +00:00
2021-03-23 18:57:58 +00:00
if [ "$_shell" = "ksh" ] || [ "$_shell" = "mksh" ] || [ "$_shell" = "zsh" ] ; then
2021-03-21 13:17:16 +00:00
_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