mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-29 05:12:55 -05:00
b6aef96cea
With e.g. /usr/local/bin/.python-version owned by some user, `pyenv local foo` would fail, if the user has no permissions for `/usr/local/bin`, but only the `.python-version` file.
24 lines
582 B
Bash
Executable file
24 lines
582 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# Usage: pyenv version-file-write <file> <version>
|
|
|
|
set -e
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
PYENV_VERSION_FILE="$1"
|
|
shift || true
|
|
versions=("$@")
|
|
|
|
if [ -z "$versions" ] || [ -z "$PYENV_VERSION_FILE" ]; then
|
|
pyenv-help --usage version-file-write >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Make sure the specified version is installed.
|
|
pyenv-prefix "${versions[@]}" >/dev/null
|
|
|
|
# Write the version out to disk.
|
|
# Create an empty file. Using "rm" might cause a permission error.
|
|
> "$PYENV_VERSION_FILE"
|
|
for version in "${versions[@]}"; do
|
|
echo "$version" >> "$PYENV_VERSION_FILE"
|
|
done
|