mirror of https://github.com/jenv/jenv.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
754 B
38 lines
754 B
#!/usr/bin/env bash |
|
# Summary: List all Java versions that contain the given executable |
|
# Usage: jenv whence [--path] <command> |
|
|
|
set -e |
|
[ -n "$JENV_DEBUG" ] && set -x |
|
|
|
# Provide jenv completions |
|
if [ "$1" = "--complete" ]; then |
|
echo --path |
|
exec jenv shims --short |
|
fi |
|
|
|
if [ "$1" = "--path" ]; then |
|
print_paths="1" |
|
shift |
|
else |
|
print_paths="" |
|
fi |
|
|
|
whence() { |
|
local command="$1" |
|
jenv-versions --bare | while read version; do |
|
path="$(jenv-prefix "$version")/bin/${command}" |
|
if [ -x "$path" ]; then |
|
[ "$print_paths" ] && echo "$path" || echo "$version" |
|
fi |
|
done |
|
} |
|
|
|
JENV_COMMAND="$1" |
|
if [ -z "$JENV_COMMAND" ]; then |
|
jenv-help --usage whence >&2 |
|
exit 1 |
|
fi |
|
|
|
result="$(whence "$JENV_COMMAND")" |
|
[ -n "$result" ] && echo "$result"
|
|
|