0

I encounterd the following output while using 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}
}

I have seen which show aliases but not bash scripts before.

This script obviously came from RVM but how did it get in to which and where can I find it on my filesystem? It isn't in .bashrc.

Qwertie
  • 1,264
  • Related: https://unix.stackexchange.com/a/85250/117549 -- quoting: "There is a GNU which which is probably the most extravagant one. It tries to extend what the which csh script did to other shells: you can tell it what your aliases and functions are so that it can give you a better answer (and I believe some Linux distributions set some global aliases around that for bash to do that)." – Jeff Schaller Jan 31 '18 at 01:20
  • See also: https://unix.stackexchange.com/q/322817/117549 – Jeff Schaller Jan 31 '18 at 01:21
  • 3
    that's not a script, it's a shell function. – cas Jan 31 '18 at 05:04

1 Answers1

0

Try this:

shopt -s extdebug
declare -F gem

From 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.
m0dular
  • 1,261