Skip to content

Commit 4929485

Browse files
authored
Merge pull request #889 from akinomyoga/failglob-4
fix(ssh): fix for failglob, etc.
2 parents ba95f05 + 92f288d commit 4929485

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

completions/ssh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ _sftp()
373373

374374
_comp_xfunc_ssh_suboption_check && return
375375

376-
local ipvx
376+
local ipvx=
377377

378378
case $prev in
379379
-*[BDlPRs])
@@ -421,7 +421,7 @@ _sftp()
421421
elif [[ $cur == -* ]]; then
422422
COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
423423
else
424-
_known_hosts_real ${ipvx-} -a ${configfile:+-F "$configfile"} -- "$cur"
424+
_known_hosts_real ${ipvx:+"$ipvx"} -a ${configfile:+-F "$configfile"} -- "$cur"
425425
fi
426426
} &&
427427
shopt -u hostcomplete && complete -F _sftp sftp
@@ -435,8 +435,6 @@ _comp_cmd_scp__path_esc='[][(){}<>"'"'"',:;^&!$=?`\\|[:space:]]'
435435
# shellcheck disable=SC2120
436436
_comp_xfunc_ssh_scp_remote_files()
437437
{
438-
local IFS=$'\n'
439-
440438
# remove backslash escape from the first colon
441439
cur=${cur/\\:/:}
442440

@@ -468,7 +466,7 @@ _comp_xfunc_ssh_scp_remote_files()
468466
command sed -e 's/'"$_comp_cmd_scp__path_esc"'/\\\\\\&/g' -e 's/[*@|=]$//g' \
469467
-e 's/[^\/]$/& /g')
470468
fi
471-
COMPREPLY+=($files)
469+
_comp_split -la COMPREPLY "$files"
472470
}
473471

474472
_comp_deprecate_func _scp_remote_files _comp_xfunc_ssh_scp_remote_files
@@ -487,12 +485,15 @@ _comp_xfunc_ssh_scp_local_files()
487485
shift
488486
fi
489487

488+
local files
489+
_comp_expand_glob files '"$cur"*'
490+
((${#files[@]})) || return 0
490491
if $dirsonly; then
491-
COMPREPLY+=($(command ls -aF1dL "$cur"* 2>/dev/null |
492+
COMPREPLY+=($(command ls -aF1dL "${files[@]}" 2>/dev/null |
492493
command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" -e '/[^\/]$/d' \
493494
-e "s/^/${1-}/"))
494495
else
495-
COMPREPLY+=($(command ls -aF1dL "$cur"* 2>/dev/null |
496+
COMPREPLY+=($(command ls -aF1dL "${files[@]}" 2>/dev/null |
496497
command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" -e 's/[*@|=]$//g' \
497498
-e 's/[^\/]$/& /g' -e "s/^/${1-}/"))
498499
fi

0 commit comments

Comments
 (0)