2012-08-31 02:23:41 -04:00
|
|
|
#!/usr/bin/env bash
|
2013-01-18 03:41:41 -05:00
|
|
|
# Usage: pyenv version-file-write <file> <version>
|
|
|
|
|
2012-08-31 02:23:41 -04:00
|
|
|
set -e
|
|
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
|
|
|
|
PYENV_VERSION_FILE="$1"
|
2014-01-02 12:05:40 -05:00
|
|
|
shift || true
|
2012-09-07 06:16:42 -04:00
|
|
|
versions=("$@")
|
2012-08-31 02:23:41 -04:00
|
|
|
|
2012-09-07 06:16:42 -04:00
|
|
|
if [ -z "$versions" ] || [ -z "$PYENV_VERSION_FILE" ]; then
|
2013-01-18 03:41:41 -05:00
|
|
|
pyenv-help --usage version-file-write >&2
|
2012-08-31 02:23:41 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure the specified version is installed.
|
2013-01-31 22:46:57 -05:00
|
|
|
pyenv-prefix "${versions[@]}" >/dev/null
|
2012-08-31 02:23:41 -04:00
|
|
|
|
|
|
|
# Write the version out to disk.
|
2012-08-31 03:09:46 -04:00
|
|
|
rm -f "$PYENV_VERSION_FILE"
|
2012-09-07 06:16:42 -04:00
|
|
|
for version in "${versions[@]}"; do
|
2012-08-31 06:39:29 -04:00
|
|
|
echo "$version" >> "$PYENV_VERSION_FILE"
|
2012-08-31 03:09:46 -04:00
|
|
|
done
|