pyenv/libexec/pyenv-version

39 lines
873 B
Text
Raw Normal View History

#!/usr/bin/env bash
# Summary: Show the current Python version(s) and its origin
# Usage: pyenv version [--bare]
2013-01-18 03:41:41 -05:00
#
# Shows the currently selected Python version(s) and how it was
# selected. To obtain only the version string, use `pyenv version
# --bare` or `pyenv version-name'.
2013-01-18 03:41:41 -05:00
set -e
[ -n "$PYENV_DEBUG" ] && set -x
exitcode=0
2013-08-15 09:29:14 -04:00
OLDIFS="$IFS"
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name)) || exitcode=$?
2013-08-15 09:29:14 -04:00
IFS="$OLDIFS"
unset bare
for arg; do
case "$arg" in
--complete )
echo --bare
exit ;;
--bare ) bare=1 ;;
* )
pyenv-help --usage version >&2
exit 1
;;
esac
done
for PYENV_VERSION_NAME in "${PYENV_VERSION_NAMES[@]}"; do
if [[ -n $bare ]]; then
echo "$PYENV_VERSION_NAME"
else
echo "$PYENV_VERSION_NAME (set by $(pyenv-version-origin))"
fi
done
exit $exitcode