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