我在使用时遇到以下输出which
[user@localhost ~]$ which gem
gem ()
{
\typeset result;
( \typeset rvmrc;
rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc");
if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]; then
rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc");
fi;
for rvmrc in "${rvm_rvmrc_files[@]}";
do
[[ -s "${rvmrc}" ]] && source "${rvmrc}" || true;
done;
unset rvm_rvmrc_files;
command gem "$@" ) || result=$?;
hash -r;
return ${result:-0}
}
我以前见过which
显示别名,但没有见过 bash 脚本。
该脚本显然来自 RVM,但它是如何进入的which
以及在我的文件系统上哪里可以找到它?它不在.bashrc
.
答案1
尝试这个:
shopt -s extdebug
declare -F gem
从man builtins
:
extdebug
If set, behavior intended for use by debuggers is enabled:
1. The -F option to the declare builtin displays the source file
name and line number corresponding to each function name sup‐
plied as an argument.