diff --git a/news/13555.bugfix.rst b/news/13555.bugfix.rst new file mode 100644 index 00000000000..d0694f610c1 --- /dev/null +++ b/news/13555.bugfix.rst @@ -0,0 +1 @@ +Fix bash completion when the ``$IFS`` variable has been modified from its default. diff --git a/src/pip/_internal/commands/completion.py b/src/pip/_internal/commands/completion.py index 6d9597bdea0..7ba205d7263 100644 --- a/src/pip/_internal/commands/completion.py +++ b/src/pip/_internal/commands/completion.py @@ -14,9 +14,10 @@ "bash": """ _pip_completion() {{ + local IFS=$' \\t\\n' COMPREPLY=( $( COMP_WORDS="${{COMP_WORDS[*]}}" \\ COMP_CWORD=$COMP_CWORD \\ - PIP_AUTO_COMPLETE=1 $1 2>/dev/null ) ) + PIP_AUTO_COMPLETE=1 "$1" 2>/dev/null ) ) }} complete -o default -F _pip_completion {prog} """, diff --git a/tests/functional/test_completion.py b/tests/functional/test_completion.py index f0396aa0c68..01a8d819c58 100644 --- a/tests/functional/test_completion.py +++ b/tests/functional/test_completion.py @@ -15,9 +15,10 @@ """\ _pip_completion() { + local IFS=$' \\t\\n' COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \\ COMP_CWORD=$COMP_CWORD \\ - PIP_AUTO_COMPLETE=1 $1 2>/dev/null ) ) + PIP_AUTO_COMPLETE=1 "$1" 2>/dev/null ) ) } complete -o default -F _pip_completion pip""", ),