25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

  1. #!/usr/bin/env bash
  2. #
  3. # Summary: Set or show the global Python version
  4. #
  5. # Usage: pyenv global <version>
  6. #
  7. # Sets the global Python version. You can override the global version at
  8. # any time by setting a directory-specific version with `pyenv local'
  9. # or by setting the `PYENV_VERSION' environment variable.
  10. #
  11. # <version> should be a string matching a Python version known to pyenv.
  12. # The special version string `system' will use your default system Python.
  13. # Run `pyenv versions' for a list of available Python versions.
  14. set -e
  15. [ -n "$PYENV_DEBUG" ] && set -x
  16. # Provide pyenv completions
  17. if [ "$1" = "--complete" ]; then
  18. echo system
  19. exec pyenv-versions --bare
  20. fi
  21. versions=("$@")
  22. PYENV_VERSION_FILE="${PYENV_ROOT}/version"
  23. if [ -n "$versions" ]; then
  24. pyenv-version-file-write "$PYENV_VERSION_FILE" "${versions[@]}"
  25. else
  26. OLDIFS="$IFS"
  27. IFS=: versions=($(
  28. pyenv-version-file-read "$PYENV_VERSION_FILE" ||
  29. pyenv-version-file-read "${PYENV_ROOT}/global" ||
  30. pyenv-version-file-read "${PYENV_ROOT}/default" ||
  31. echo system
  32. ))
  33. IFS="$OLDIFS"
  34. for version in "${versions[@]}"; do
  35. echo "$version"
  36. done
  37. fi