]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bash-completion: fix variable leaks of "IFS" and "word"
authorKoichi Murase <myoga.murase@gmail.com>
Sun, 14 Nov 2021 06:06:40 +0000 (15:06 +0900)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 23 Nov 2021 12:35:36 +0000 (13:35 +0100)
Signed-off-by: Koichi Murase <myoga.murase@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/bash-completion/vsh.in

index 70ade50a02cc43945a7cd68e85d2c56c200cdd1d..897f74cc0863c402c4aaee91a5beff2b34d9b989 100644 (file)
@@ -21,7 +21,7 @@ _@command@_complete()
     # See what URI is user trying to connect to and if they are
     # connecting RO. Honour that.
     while [ $c -le $COMP_CWORD ]; do
-        word="${COMP_WORDS[c]}"
+        local word="${COMP_WORDS[c]}"
         case "$word" in
             -r|--readonly) RO=1 ;;
             -c|--connect) c=$((++c)); URI=${COMP_WORDS[c]} ;;
@@ -56,7 +56,8 @@ _@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"