Skip to content

Commit eeadd25

Browse files
committed
fix(ssh): avoid variable conflicts
1 parent d25aee4 commit eeadd25

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
@@ -276,7 +276,7 @@ _comp_xfunc_ssh_identityfile()
276276
local cur=$cur tmp
277277
[[ ! $cur && -d ~/.ssh ]] && cur=~/.ssh/id
278278
_comp_compgen -v tmp -c "$cur" filedir &&
279-
_comp_compgen -- -W '"${tmp[@]}"' -X "${1:+!}*.pub"
279+
_comp_compgen -U tmp -- -W '"${tmp[@]}"' -X "${1:+!}*.pub"
280280
}
281281

282282
_comp_deprecate_func 2.12 _ssh_identityfile _comp_xfunc_ssh_identityfile
@@ -460,35 +460,35 @@ _comp_xfunc_scp_remote_files()
460460
# remove backslash escape from the first colon
461461
cur=${cur/\\:/:}
462462

463-
local userhost=${cur%%?(\\):*}
464-
local path=${cur#*:}
463+
local _userhost=${cur%%?(\\):*}
464+
local _path=${cur#*:}
465465

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

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

475-
local files
475+
local _files
476476
if [[ ${1-} == -d ]]; then
477477
# escape problematic characters; remove non-dirs
478478
# shellcheck disable=SC2090
479-
files=$(ssh -o 'Batchmode yes' "$userhost" \
480-
command ls -aF1dL "$path*" 2>/dev/null |
479+
_files=$(ssh -o 'Batchmode yes' "$_userhost" \
480+
command ls -aF1dL "$_path*" 2>/dev/null |
481481
command sed -e 's/'"$_comp_cmd_scp__path_esc"'/\\\\\\&/g' -e '/[^\/]$/d')
482482
else
483483
# escape problematic characters; remove executables, aliases, pipes
484484
# and sockets; add space at end of file names
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 's/[*@|=]$//g' \
489489
-e 's/[^\/]$/& /g')
490490
fi
491-
_comp_split -la COMPREPLY "$files"
491+
_comp_split -la COMPREPLY "$_files"
492492
}
493493

494494
_comp_deprecate_func 2.12 _scp_remote_files _comp_xfunc_scp_remote_files

0 commit comments

Comments
 (0)