[PATCH 1/1] bash-completion: fix variable leaks of "IFS" and "word"

Koichi Murase myoga.murase at gmail.com
Sun Nov 14 06:06:40 UTC 2021


---
 tools/bash-completion/vsh.in | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/bash-completion/vsh.in b/tools/bash-completion/vsh.in
index 70ade50a02..4399ff0a64 100644
--- a/tools/bash-completion/vsh.in
+++ b/tools/bash-completion/vsh.in
@@ -4,7 +4,7 @@
 
 _ at command@_complete()
 {
-    local words cword c=0 i=0 cur RO URI CMDLINE INPUT A
+    local words cword c=0 i=0 cur word RO URI CMDLINE INPUT A
 
     # Here, $COMP_WORDS is an array of words on the bash
     # command line that user wants to complete. However, when
@@ -56,7 +56,8 @@ _ at command@_complete()
     # the name of the command whose arguments are being
     # completed.
     # Therefore, we might just run $1.
-    IFS=$'\n' A=($($1 ${CMDLINE[@]} complete -- "${INPUT[@]}" 2>/dev/null))
+    local IFS=$'\n'
+    A=($($1 ${CMDLINE[@]} complete -- "${INPUT[@]}" 2>/dev/null))
 
     COMPREPLY=($(compgen -W "${A[*]%--}" -- ${cur}))
     __ltrim_colon_completions "$cur"
-- 
2.21.3




More information about the libvir-list mailing list