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 if [ -n "$versions" ]; then
pyenv-version-file-write "$PYENV_VERSION_FILE" "${versions[@]}" pyenv-version-file-write "$PYENV_VERSION_FILE" "${versions[@]}"
else else
OLDIFS="$IFS"
IFS=: versions=($( IFS=: versions=($(
pyenv-version-file-read "$PYENV_VERSION_FILE" || pyenv-version-file-read "$PYENV_VERSION_FILE" ||
pyenv-version-file-read "${PYENV_ROOT}/global" || pyenv-version-file-read "${PYENV_ROOT}/global" ||
pyenv-version-file-read "${PYENV_ROOT}/default" || pyenv-version-file-read "${PYENV_ROOT}/default" ||
echo system echo system
)) ))
IFS="$OLDIFS"
for version in "${versions[@]}"; do for version in "${versions[@]}"; do
echo "$version" echo "$version"
done done

View file

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

View file

@ -17,10 +17,14 @@ fi
if [ -n "$1" ]; then if [ -n "$1" ]; then
versions=($@) versions=($@)
OLDIFS="$IFS"
IFS=: PYENV_VERSION="${versions[*]}" IFS=: PYENV_VERSION="${versions[*]}"
IFS="$OLDIFS"
export PYENV_VERSION export PYENV_VERSION
else else
OLDIFS="$IFS"
IFS=: versions=($(pyenv-version-name)) IFS=: versions=($(pyenv-version-name))
IFS="$OLDIFS"
fi fi
PYENV_PREFIX_PATHS=() PYENV_PREFIX_PATHS=()
@ -39,4 +43,8 @@ for version in "${versions[@]}"; do
fi fi
done 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. # Make sure the specified version is installed.
if pyenv-prefix "${versions[@]}" >/dev/null; then if pyenv-prefix "${versions[@]}" >/dev/null; then
OLDIFS="$IFS"
IFS=: PYENV_VERSION="${versions[*]}" IFS=: PYENV_VERSION="${versions[*]}"
IFS="$OLDIFS"
echo "export PYENV_VERSION=\"${PYENV_VERSION}\"" echo "export PYENV_VERSION=\"${PYENV_VERSION}\""
else else
echo "return 1" echo "return 1"

View file

@ -8,7 +8,9 @@
set -e set -e
[ -n "$PYENV_DEBUG" ] && set -x [ -n "$PYENV_DEBUG" ] && set -x
OLDIFS="$IFS"
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name)) IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name))
IFS="$OLDIFS"
for PYENV_VERSION_NAME in "${PYENV_VERSION_NAMES[@]}"; do for PYENV_VERSION_NAME in "${PYENV_VERSION_NAMES[@]}"; do
echo "$PYENV_VERSION_NAME (set by $(pyenv-version-origin))" 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 ) done < <( cat "$VERSION_FILE" && echo )
if [ -n "$versions" ]; then if [ -n "$versions" ]; then
{ OLDIFS="$IFS"
IFS=: { IFS=:
echo "${versions[*]}" echo "${versions[*]}"
} }
IFS="$OLDIFS"
exit exit
fi fi
fi fi

View file

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

View file

@ -16,7 +16,9 @@ if [ "$1" = "--bare" ]; then
else else
hit_prefix="* " hit_prefix="* "
miss_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))" version_origin=" (set by $(pyenv-version-origin))"
include_system="1" include_system="1"
fi fi

View file

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