pyenv-version-file-write: do not use rm, but clobber the file

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.
This commit is contained in:
Daniel Hahler 2014-09-07 16:56:40 +02:00
parent 2297bd3741
commit b6aef96cea

View file

@ -17,7 +17,8 @@ fi
pyenv-prefix "${versions[@]}" >/dev/null pyenv-prefix "${versions[@]}" >/dev/null
# Write the version out to disk. # Write the version out to disk.
rm -f "$PYENV_VERSION_FILE" # Create an empty file. Using "rm" might cause a permission error.
> "$PYENV_VERSION_FILE"
for version in "${versions[@]}"; do for version in "${versions[@]}"; do
echo "$version" >> "$PYENV_VERSION_FILE" echo "$version" >> "$PYENV_VERSION_FILE"
done done