From b6aef96cea7253db761e54c25d36ee650331c6e8 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 7 Sep 2014 16:56:40 +0200 Subject: [PATCH] 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. --- libexec/pyenv-version-file-write | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libexec/pyenv-version-file-write b/libexec/pyenv-version-file-write index 5ec01b6c..7095140f 100755 --- a/libexec/pyenv-version-file-write +++ b/libexec/pyenv-version-file-write @@ -17,7 +17,8 @@ fi pyenv-prefix "${versions[@]}" >/dev/null # 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 echo "$version" >> "$PYENV_VERSION_FILE" done