Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zsh `which rvm` or `which gem` returns the function contents instead of the path

Tags:

zsh

rvm

I've never had this problem before with my other machines but for some reason in ZSH whenever I type

which gem

or

which rvm

I get the function contents:

gem () {
local result
command gem "$@"
result="$?" 
hash -r
return $result
}

instead of it's path. For the life of me I can not figure out why this is happening.

If I switch over to bash I do not have these problems.

like image 660
user770148 Avatar asked Oct 10 '11 23:10

user770148


1 Answers

This is normal behavior for zsh. The which built-in is equivalent to whence -c, which shows the definitions of functions. Use whence, possibly with a combination of options that does not include -f or -c, if you don't want this. For example whence -w gem will display gem: function. If you only want to search for external executables (and not aliases, built-ins, reserved words or functions), use whence -v.

like image 168
Gilles 'SO- stop being evil' Avatar answered Oct 13 '22 00:10

Gilles 'SO- stop being evil'