2011-08-12 05:33:45 -04:00
|
|
|
#!/usr/bin/env bash
|
2012-12-12 23:48:28 -05:00
|
|
|
# Summary: List all Ruby versions with the given command installed
|
2012-12-29 13:06:20 -05:00
|
|
|
# Usage: rbenv whence [--path] COMMAND
|
|
|
|
|
2011-08-12 05:33:45 -04:00
|
|
|
set -e
|
2011-09-12 11:11:59 -04:00
|
|
|
[ -n "$RBENV_DEBUG" ] && set -x
|
2011-08-03 00:31:19 -04:00
|
|
|
|
2011-09-13 13:59:59 -04:00
|
|
|
# Provide rbenv completions
|
|
|
|
if [ "$1" = "--complete" ]; then
|
|
|
|
echo --path
|
|
|
|
exec rbenv shims --short
|
|
|
|
fi
|
|
|
|
|
2011-08-03 00:31:19 -04:00
|
|
|
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"
|
2011-08-03 01:06:23 -04:00
|
|
|
if [ -z "$RBENV_COMMAND" ]; then
|
2012-12-12 23:48:28 -05:00
|
|
|
rbenv-help whence | head -1 >&2
|
2011-08-03 01:06:23 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-08-03 00:31:19 -04:00
|
|
|
result="$(whence "$RBENV_COMMAND")"
|
|
|
|
[ -n "$result" ] && echo "$result"
|