2012-08-31 06:23:41 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
|
2012-09-07 10:56:55 +00:00
|
|
|
array_exists() {
|
|
|
|
local x car="$1"
|
|
|
|
shift
|
|
|
|
for x in "$@"; do
|
|
|
|
[ "${x}" = "${car}" ] && return 0
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2012-08-31 07:09:46 +00:00
|
|
|
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name))
|
2012-08-31 06:23:41 +00:00
|
|
|
|
|
|
|
if [ "$1" = "--bare" ]; then
|
|
|
|
hit_prefix=""
|
|
|
|
miss_prefix=""
|
2012-09-07 10:56:55 +00:00
|
|
|
version_origin=""
|
2012-08-31 06:23:41 +00:00
|
|
|
else
|
|
|
|
hit_prefix="* "
|
|
|
|
miss_prefix=" "
|
2012-09-07 10:56:55 +00:00
|
|
|
version_origin=" (set by $(pyenv-version-origin))"
|
2012-08-31 06:23:41 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
for path in "${PYENV_ROOT}/versions/"*; do
|
|
|
|
if [ -d "$path" ]; then
|
|
|
|
version="${path##*/}"
|
|
|
|
|
2012-09-07 10:56:55 +00:00
|
|
|
if array_exists "$version" "${PYENV_VERSION_NAMES[@]}"; then
|
|
|
|
echo "${hit_prefix}${version}${version_origin}"
|
2012-08-31 06:23:41 +00:00
|
|
|
else
|
|
|
|
echo "${miss_prefix}${version}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|