2012-08-31 06:23:41 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
|
|
|
|
# Provide pyenv completions
|
|
|
|
if [ "$1" = "--complete" ]; then
|
|
|
|
echo --unset
|
|
|
|
echo system
|
|
|
|
exec pyenv-versions --bare
|
|
|
|
fi
|
|
|
|
|
2012-08-31 07:09:46 +00:00
|
|
|
versions=()
|
|
|
|
for version in "$@"; do
|
|
|
|
versions=("${versions[@]}" "$version")
|
|
|
|
done
|
2012-08-31 06:23:41 +00:00
|
|
|
|
2012-08-31 07:09:46 +00:00
|
|
|
if [ -z "$versions" ]; then
|
|
|
|
if [ -z "$PYENV_VERSIONS" ]; then
|
2012-08-31 06:23:41 +00:00
|
|
|
echo "pyenv: no shell-specific version configured" >&2
|
|
|
|
exit 1
|
|
|
|
else
|
2012-08-31 07:09:46 +00:00
|
|
|
echo "echo \"\$PYENV_VERSIONS\""
|
2012-08-31 06:23:41 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-08-31 07:09:46 +00:00
|
|
|
if [ "$versions" = "--unset" ]; then
|
|
|
|
echo "unset PYENV_VERSIONS"
|
2012-08-31 06:23:41 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure the specified version is installed.
|
2012-08-31 07:09:46 +00:00
|
|
|
pyenv-prefix $versions >/dev/null
|
2012-08-31 06:23:41 +00:00
|
|
|
|
2012-08-31 07:09:46 +00:00
|
|
|
{
|
|
|
|
IFS=:
|
|
|
|
echo "export PYENV_VERSIONS=\"${versions[*]}\""
|
|
|
|
}
|