25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

52 satır
1.2 KiB

11 yıl önce
  1. #!/usr/bin/env bash
  2. #
  3. # Summary: Set or show the shell-specific Python version
  4. #
  5. # Usage: pyenv shell <version>
  6. # pyenv shell --unset
  7. #
  8. # Sets a shell-specific Python version by setting the `PYENV_VERSION'
  9. # environment variable in your shell. This version overrides local
  10. # application-specific versions and the global version.
  11. #
  12. # <version> should be a string matching a Python version known to pyenv.
  13. # The special version string `system' will use your default system Python.
  14. # Run `pyenv versions' for a list of available Python versions.
  15. set -e
  16. [ -n "$PYENV_DEBUG" ] && set -x
  17. # Provide pyenv completions
  18. if [ "$1" = "--complete" ]; then
  19. echo --unset
  20. echo system
  21. exec pyenv-versions --bare
  22. fi
  23. versions=("$@")
  24. if [ -z "$versions" ]; then
  25. if [ -z "$PYENV_VERSION" ]; then
  26. echo "pyenv: no shell-specific version configured" >&2
  27. exit 1
  28. else
  29. echo "echo \"\$PYENV_VERSION\""
  30. exit
  31. fi
  32. fi
  33. if [ "$versions" = "--unset" ]; then
  34. echo "set -e PYENV_VERSION"
  35. exit
  36. fi
  37. # Make sure the specified version is installed.
  38. if pyenv-prefix "${versions[@]}" >/dev/null; then
  39. OLDIFS="$IFS"
  40. IFS=: PYENV_VERSION="${versions[*]}"
  41. IFS="OLDIFS"
  42. echo "setenv PYENV_VERSION \"${PYENV_VERSION}\""
  43. else
  44. echo "false"
  45. exit 1
  46. fi