From c483e44cb4a766796012cc5031618870eff7619c Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 23 Apr 2026 18:02:22 -0400 Subject: [PATCH] Fix incorrect IFS handling The echo "${VIRTUALENV_PREFIX_PATHS[*]}" statement at the end of the file only worked by accident because IFS=: was set earlier in the file. Properly set/unset IFS. --- bin/pyenv-virtualenv-prefix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/pyenv-virtualenv-prefix b/bin/pyenv-virtualenv-prefix index b46077f..c565e6f 100755 --- a/bin/pyenv-virtualenv-prefix +++ b/bin/pyenv-virtualenv-prefix @@ -26,13 +26,17 @@ if [ -z "$PYENV_ROOT" ]; then PYENV_ROOT="${HOME}/.pyenv" fi +OLDIFS="$IFS" +IFS=: if [ -n "$1" ]; then - versions=($@) - IFS=: PYENV_VERSION="${versions[*]}" + # $@ is not affected by IFS + versions=("$@") + PYENV_VERSION="${versions[*]}" export PYENV_VERSION else - IFS=: versions=($(pyenv-version-name)) + versions=($(pyenv-version-name)) fi +IFS="$OLDIFS" append_virtualenv_prefix() { if [ -d "${VIRTUALENV_PREFIX_PATH}" ]; then @@ -101,4 +105,7 @@ for version in "${versions[@]}"; do fi done -IFS=: echo "${VIRTUALENV_PREFIX_PATHS[*]}" +OLDIFS="$IFS" +IFS=: +echo "${VIRTUALENV_PREFIX_PATHS[*]}" +IFS="$OLDIFS"