Add rbenv-whence to show you which versions of Ruby have a given command

This commit is contained in:
Sam Stephenson 2011-08-02 23:31:19 -05:00
parent 652135db7f
commit d257b562e5

22
libexec/rbenv-whence Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash -e
if [ "$1" = "--path" ]; then
print_paths="1"
shift
else
print_paths=""
fi
whence() {
local command="$1"
rbenv-versions --bare | while read version; do
path="$(rbenv-prefix "$version")/bin/${command}"
if [ -x "$path" ]; then
[ "$print_paths" ] && echo "$path" || echo "$version"
fi
done
}
RBENV_COMMAND="$1"
result="$(whence "$RBENV_COMMAND")"
[ -n "$result" ] && echo "$result"