pyenv/libexec/pyenv-version-file-write

24 lines
562 B
Text
Raw Normal View History

2013-01-18 08:41:41 +00:00
# Usage: pyenv version-file-write <file> <version>
set -e
[ -n "$PYENV_DEBUG" ] && set -x
PYENV_VERSION_FILE="$1"
2014-01-02 17:05:40 +00:00
shift || true
versions=("$@")
if [ -z "$versions" ] || [ -z "$PYENV_VERSION_FILE" ]; then
2013-01-18 08:41:41 +00:00
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