2011-08-12 05:33:45 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
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
|
|
|
|
echo "usage: rbenv whence [--path] COMMAND" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-08-03 00:31:19 -04:00
|
|
|
result="$(whence "$RBENV_COMMAND")"
|
|
|
|
[ -n "$result" ] && echo "$result"
|