pyenv/libexec/pyenv-versions

42 lines
848 B
Text
Raw Normal View History

#!/usr/bin/env bash
2013-01-18 03:41:41 -05:00
# Summary: List all Python versions available to pyenv
# Usage: pyenv versions [--bare]
#
# Lists all Python versions found in `$PYENV_ROOT/versions/*'.
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