pyenv/libexec/rbenv-whence
Andreas Johansson 6938692ca2 Fix argument that cannot be sent to bash via env
/usr/bin/env seems to have problems with arguments to bash on some
platforms. To bypass this, use set -e instead.
2011-08-12 11:33:45 +02:00

28 lines
534 B
Bash
Executable file

#!/usr/bin/env bash
set -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"
if [ -z "$RBENV_COMMAND" ]; then
echo "usage: rbenv whence [--path] COMMAND" >&2
exit 1
fi
result="$(whence "$RBENV_COMMAND")"
[ -n "$result" ] && echo "$result"