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