Skip to content

Commit bf16bf6

Browse files
committed
fix(ssh): avoid variable conflicts
1 parent d868beb commit bf16bf6

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

completions/ssh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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)