Debian Codegraph @

libexec/pyenv-whence

raw symbols SCIP
1 #!/usr/bin/env bash
2 # Summary: List all Python versions that contain the given executable
3 # Usage: pyenv whence [--path] <command>
4
5 set -e
6 [ -n "$PYENV_DEBUG" ] && set -x
7
8 # Provide pyenv completions
9 if [ "$1" = "--complete" ]; then
10 echo --path
11 exec pyenv-shims --short
12 fi
13
14 if [ "$1" = "--path" ]; then
15 print_paths="1"
16 shift
17 else
18 print_paths=""
19 fi
20
21 whence() {
22 local command="$1"
23 pyenv-versions --bare | while read -r version; do
24 path="$(pyenv-prefix "$version")/bin/${command}"
25 if [ -x "$path" ]; then
26 [ "$print_paths" ] && echo "$path" || echo "$version"
27 fi
28 done
29 }
30
31 PYENV_COMMAND="$1"
32 if [ -z "$PYENV_COMMAND" ]; then
33 pyenv-help --usage whence >&2
34 exit 1
35 fi
36
37 result="$(whence "$PYENV_COMMAND")"
38 [ -n "$result" ] && echo "$result"