Skip to content

Commit f2df91d

Browse files
committed
fix(ssh): avoid variable conflicts
1 parent bef94c3 commit f2df91d

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

completions/ssh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ _comp_cmd_ssh__compgen_queries()
88
key-plain key-sig protocol-version compression sig ciphers macs
99
kexalgorithms pubkeyacceptedkeytypes hostkeyalgorithms
1010
hostbasedkeytypes hostbasedacceptedkeytypes)
11-
_comp_compgen -c "${cur,,}" -- -W '"${ret[@]}" help"'
11+
_comp_compgen -c "${cur,,}" -U ret -- -W '"${ret[@]}" help"'
1212
}
1313

1414
# @since 2.12
@@ -37,7 +37,7 @@ _comp_cmd_ssh__compgen_ciphers()
3737
[[ ${ret-} ]] || ret=(3des-cbc aes128-cbc aes192-cbc aes256-cbc
3838
aes128-ctr aes192-ctr aes256-ctr arcfour128 arcfour256 arcfour
3939
blowfish-cbc cast128-cbc)
40-
_comp_compgen -- -W '"${ret[@]}"'
40+
_comp_compgen -U ret -- -W '"${ret[@]}"'
4141
}
4242

4343
_comp_cmd_ssh__compgen_macs()
@@ -46,7 +46,7 @@ _comp_cmd_ssh__compgen_macs()
4646
_comp_compgen -v ret -i ssh query "$1" mac
4747
[[ ${ret-} ]] || ret=(hmac-md5 hmac-sha1 [email protected]
4848
hmac-ripemd160 hmac-sha1-96 hmac-md5-96)
49-
_comp_compgen -- -W '"${ret[@]}"'
49+
_comp_compgen -U ret -- -W '"${ret[@]}"'
5050
}
5151

5252
# @since 2.12
@@ -283,7 +283,7 @@ _comp_xfunc_ssh_compgen_identityfile()
283283
local cur=$cur tmp
284284
[[ ! $cur && -d ~/.ssh ]] && cur=~/.ssh/id
285285
_comp_compgen -v tmp -c "$cur" filedir &&
286-
_comp_compgen -- -W '"${tmp[@]}"' -X "${1:+!}*.pub"
286+
_comp_compgen -U tmp -- -W '"${tmp[@]}"' -X "${1:+!}*.pub"
287287
}
288288

289289
_comp_deprecate_func 2.12 _ssh_identityfile _comp_xfunc_ssh_compgen_identityfile
@@ -467,35 +467,35 @@ _comp_xfunc_scp_compgen_remote_files()
467467
# remove backslash escape from the first colon
468468
cur=${cur/\\:/:}
469469

470-
local userhost=${cur%%?(\\):*}
471-
local path=${cur#*:}
470+
local _userhost=${cur%%?(\\):*}
471+
local _path=${cur#*:}
472472

473473
# unescape (3 backslashes to 1 for chars we escaped)
474474
# shellcheck disable=SC2090
475-
path=$(command sed -e 's/\\\\\\\('"$_comp_cmd_scp__path_esc"'\)/\\\1/g' <<<"$path")
475+
_path=$(command sed -e 's/\\\\\\\('"$_comp_cmd_scp__path_esc"'\)/\\\1/g' <<<"$_path")
476476

477477
# default to home dir of specified user on remote host
478-
if [[ ! $path ]]; then
479-
path=$(ssh -o 'Batchmode yes' "$userhost" pwd 2>/dev/null)
478+
if [[ ! $_path ]]; then
479+
_path=$(ssh -o 'Batchmode yes' "$_userhost" pwd 2>/dev/null)
480480
fi
481481

482-
local files
482+
local _files
483483
if [[ ${1-} == -d ]]; then
484484
# escape problematic characters; remove non-dirs
485485
# shellcheck disable=SC2090
486-
files=$(ssh -o 'Batchmode yes' "$userhost" \
487-
command ls -aF1dL "$path*" 2>/dev/null |
486+
_files=$(ssh -o 'Batchmode yes' "$_userhost" \
487+
command ls -aF1dL "$_path*" 2>/dev/null |
488488
command sed -e 's/'"$_comp_cmd_scp__path_esc"'/\\\\\\&/g' -e '/[^\/]$/d')
489489
else
490490
# escape problematic characters; remove executables, aliases, pipes
491491
# and sockets; add space at end of file names
492492
# shellcheck disable=SC2090
493-
files=$(ssh -o 'Batchmode yes' "$userhost" \
494-
command ls -aF1dL "$path*" 2>/dev/null |
493+
_files=$(ssh -o 'Batchmode yes' "$_userhost" \
494+
command ls -aF1dL "$_path*" 2>/dev/null |
495495
command sed -e 's/'"$_comp_cmd_scp__path_esc"'/\\\\\\&/g' -e 's/[*@|=]$//g' \
496496
-e 's/[^\/]$/& /g')
497497
fi
498-
_comp_split -l COMPREPLY "$files"
498+
_comp_compgen_split -l -- "$_files"
499499
}
500500

501501
# @deprecated 2.12 use `_comp_compgen -ax ssh remote_files` instead

0 commit comments

Comments
 (0)