pyenv/libexec/pyenv-versions

37 lines
694 B
Text
Raw Normal View History

#!/usr/bin/env bash
set -e
[ -n "$PYENV_DEBUG" ] && set -x
array_exists() {
local x car="$1"
shift
for x in "$@"; do
[ "${x}" = "${car}" ] && return 0
done
return 1
}
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name))
if [ "$1" = "--bare" ]; then
hit_prefix=""
miss_prefix=""
version_origin=""
else
hit_prefix="* "
miss_prefix=" "
version_origin=" (set by $(pyenv-version-origin))"
fi
for path in "${PYENV_ROOT}/versions/"*; do
if [ -d "$path" ]; then
version="${path##*/}"
if array_exists "$version" "${PYENV_VERSION_NAMES[@]}"; then
echo "${hit_prefix}${version}${version_origin}"
else
echo "${miss_prefix}${version}"
fi
fi
done