From 403f4eb7a710062f6f7968d3ba93e02193e8a89e Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Thu, 15 Aug 2013 22:29:14 +0900 Subject: [PATCH] Preserve original IFSs --- libexec/pyenv-global | 2 ++ libexec/pyenv-local | 2 ++ libexec/pyenv-prefix | 10 +++++++++- libexec/pyenv-sh-shell | 2 ++ libexec/pyenv-version | 2 ++ libexec/pyenv-version-file-read | 5 +++-- libexec/pyenv-version-name | 4 ++++ libexec/pyenv-versions | 4 +++- libexec/pyenv-which | 4 ++++ 9 files changed, 31 insertions(+), 4 deletions(-) diff --git a/libexec/pyenv-global b/libexec/pyenv-global index 2bc13ce4..b2ea4b6d 100755 --- a/libexec/pyenv-global +++ b/libexec/pyenv-global @@ -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 diff --git a/libexec/pyenv-local b/libexec/pyenv-local index 7cb1a4d2..8bb40fab 100755 --- a/libexec/pyenv-local +++ b/libexec/pyenv-local @@ -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 diff --git a/libexec/pyenv-prefix b/libexec/pyenv-prefix index 80c033a8..f305b626 100755 --- a/libexec/pyenv-prefix +++ b/libexec/pyenv-prefix @@ -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" diff --git a/libexec/pyenv-sh-shell b/libexec/pyenv-sh-shell index ef30c49a..245c2687 100755 --- a/libexec/pyenv-sh-shell +++ b/libexec/pyenv-sh-shell @@ -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" diff --git a/libexec/pyenv-version b/libexec/pyenv-version index efd9eadc..cec2c945 100755 --- a/libexec/pyenv-version +++ b/libexec/pyenv-version @@ -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))" diff --git a/libexec/pyenv-version-file-read b/libexec/pyenv-version-file-read index cd752660..c5d5a435 100755 --- a/libexec/pyenv-version-file-read +++ b/libexec/pyenv-version-file-read @@ -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 diff --git a/libexec/pyenv-version-name b/libexec/pyenv-version-name index 88c50822..ceb047fb 100755 --- a/libexec/pyenv-version-name +++ b/libexec/pyenv-version-name @@ -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 diff --git a/libexec/pyenv-versions b/libexec/pyenv-versions index 9c745a5a..4434cc1b 100755 --- a/libexec/pyenv-versions +++ b/libexec/pyenv-versions @@ -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 diff --git a/libexec/pyenv-which b/libexec/pyenv-which index 3a1b9a0e..82da05e8 100755 --- a/libexec/pyenv-which +++ b/libexec/pyenv-which @@ -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