From 097296c30b72f472bcf4e72cf8ab2aeb55903c49 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 14 Nov 2021 15:06:40 +0900 Subject: [PATCH] bash-completion: fix variable leaks of "IFS" and "word" Signed-off-by: Koichi Murase Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- 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..897f74cc08 100644 --- a/tools/bash-completion/vsh.in +++ b/tools/bash-completion/vsh.in @@ -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" -- 2.47.2