pyenv/libexec/pyenv-version-file-write
Casey McGinty 83e5459cfb Remove shebang lines from scripts for performance
All scripts in libexec/ (excluding pyenv) are called through pyenv,
therefore the shebang lines are not necessary. On some systems this
provides a measurable increase in performance of the shell prompt.

Related to pyenv/pyenv-virtualenv#259
2019-03-07 22:15:14 +01:00

23 lines
562 B
Text
Executable file

# 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