Preserve original IFSs

This commit is contained in:
Yamashita Yuu 2013-08-15 22:29:14 +09:00
parent 4c71f3c5cd
commit 403f4eb7a7
9 changed files with 31 additions and 4 deletions

View file

@ -27,12 +27,14 @@ PYENV_VERSION_FILE="${PYENV_ROOT}/version"
if [ -n "$versions" ]; then
pyenv-version-file-write "$PYENV_VERSION_FILE" "${versions[@]}"
else
OLDIFS="$IFS"
IFS=: versions=($(
pyenv-version-file-read "$PYENV_VERSION_FILE" ||
pyenv-version-file-read "${PYENV_ROOT}/global" ||
pyenv-version-file-read "${PYENV_ROOT}/default" ||
echo system
))
IFS="$OLDIFS"
for version in "${versions[@]}"; do
echo "$version"
done

View file

@ -46,6 +46,7 @@ elif [ -n "$versions" ]; then
fi
pyenv-version-file-write .python-version "${versions[@]}"
else
OLDIFS="$IFS"
IFS=: versions=($(
pyenv-version-file-read .python-version ||
pyenv-version-file-read .pyenv-version ||
@ -53,6 +54,7 @@ else
exit 1
} >&2
))
IFS="$OLDIFS"
for version in "${versions[@]}"; do
echo "$version"
done

View file

@ -17,10 +17,14 @@ fi
if [ -n "$1" ]; then
versions=($@)
OLDIFS="$IFS"
IFS=: PYENV_VERSION="${versions[*]}"
IFS="$OLDIFS"
export PYENV_VERSION
else
OLDIFS="$IFS"
IFS=: versions=($(pyenv-version-name))
IFS="$OLDIFS"
fi
PYENV_PREFIX_PATHS=()
@ -39,4 +43,8 @@ for version in "${versions[@]}"; do
fi
done
IFS=: echo "${PYENV_PREFIX_PATHS[*]}"
OLDIFS="$IFS"
{ IFS=:
echo "${PYENV_PREFIX_PATHS[*]}"
}
IFS="$OLDIFS"

View file

@ -42,7 +42,9 @@ fi
# Make sure the specified version is installed.
if pyenv-prefix "${versions[@]}" >/dev/null; then
OLDIFS="$IFS"
IFS=: PYENV_VERSION="${versions[*]}"
IFS="$OLDIFS"
echo "export PYENV_VERSION=\"${PYENV_VERSION}\""
else
echo "return 1"

View file

@ -8,7 +8,9 @@
set -e
[ -n "$PYENV_DEBUG" ] && set -x
OLDIFS="$IFS"
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name))
IFS="$OLDIFS"
for PYENV_VERSION_NAME in "${PYENV_VERSION_NAMES[@]}"; do
echo "$PYENV_VERSION_NAME (set by $(pyenv-version-origin))"

View file

@ -18,10 +18,11 @@ if [ -e "$VERSION_FILE" ]; then
done < <( cat "$VERSION_FILE" && echo )
if [ -n "$versions" ]; then
{
IFS=:
OLDIFS="$IFS"
{ IFS=:
echo "${versions[*]}"
}
IFS="$OLDIFS"
exit
fi
fi

View file

@ -4,11 +4,15 @@ set -e
[ -n "$PYENV_DEBUG" ] && set -x
if [ -n "$PYENV_VERSION" ]; then
OLDIFS="$IFS"
IFS=: versions=($(echo "${PYENV_VERSION}"))
IFS="$IFS"
else
PYENV_VERSION_FILE="$(pyenv-version-file)"
OLDIFS="$IFS"
IFS=: versions=($(pyenv-version-file-read "$PYENV_VERSION_FILE" || true))
IFS=: PYENV_VERSION="${versions[*]}"
IFS="$OLDIFS"
export PYENV_VERSION
fi

View file

@ -16,7 +16,9 @@ if [ "$1" = "--bare" ]; then
else
hit_prefix="* "
miss_prefix=" "
current_versions=($(IFS=:; for version in $(pyenv-version-name); do echo "$version"; done || true))
OLDIFS="$IFS"
IFS=: current_versions=($(pyenv-version-name || true))
IFS="$OLDIFS"
version_origin=" (set by $(pyenv-version-origin))"
include_system="1"
fi

View file

@ -36,7 +36,9 @@ remove_from_path() {
fi
local paths
OLDIFS="$IFS"
IFS=: paths=($PATH)
IFS="$OLDIFS"
for path in "${paths[@]}"; do
path="$(expand_path "$path" || true)"
@ -48,8 +50,10 @@ remove_from_path() {
echo "${result%:}"
}
OLDIFS="$IFS"
IFS=: versions=($(pyenv-version-name))
IFS=: PYENV_VERSION="${versions[*]}"
IFS="$OLDIFS"
PYENV_COMMAND="$1"
if [ -z "$PYENV_COMMAND" ]; then