which/which2.sh

19 lines
405 B
Bash

# shellcheck shell=sh
# 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