which/which2.sh

19 lines
471 B
Bash
Raw Normal View History

2021-03-23 19:15:21 +00:00
# shellcheck shell=sh
# Initialization script for bash, sh, mksh and ksh
2021-04-26 12:02:33 +00:00
which_shell="$(cat /proc/$$/comm)"
2021-04-26 12:02:33 +00:00
if [ "$which_shell" = "ksh" ] || [ "$which_shell" = "mksh" ] || [ "$which_shell" = "zsh" ] ; then
alias which_declare="typeset -fS"
2021-04-26 12:02:33 +00:00
which_opt=""
else
which_opt="-f"
alias which_declare="declare -f"
fi
which () {
(alias; which_declare) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
}
2021-04-26 12:02:33 +00:00
export ${which_opt} which