@@ -373,7 +373,7 @@ _sftp()
373
373
374
374
_comp_xfunc_ssh_suboption_check && return
375
375
376
- local ipvx
376
+ local ipvx=
377
377
378
378
case $prev in
379
379
-* [BDlPRs])
@@ -421,7 +421,7 @@ _sftp()
421
421
elif [[ $cur == -* ]]; then
422
422
COMPREPLY=($( compgen -W ' $(_parse_usage "$1")' -- " $cur " ) )
423
423
else
424
- _known_hosts_real ${ipvx- } -a ${configfile: +-F " $configfile " } -- " $cur "
424
+ _known_hosts_real ${ipvx: + " $ipvx " } -a ${configfile: +-F " $configfile " } -- " $cur "
425
425
fi
426
426
} &&
427
427
shopt -u hostcomplete && complete -F _sftp sftp
@@ -435,8 +435,6 @@ _comp_cmd_scp__path_esc='[][(){}<>"'"'"',:;^&!$=?`\\|[:space:]]'
435
435
# shellcheck disable=SC2120
436
436
_comp_xfunc_ssh_scp_remote_files ()
437
437
{
438
- local IFS=$' \n '
439
-
440
438
# remove backslash escape from the first colon
441
439
cur=${cur/ \\ :/: }
442
440
@@ -468,7 +466,7 @@ _comp_xfunc_ssh_scp_remote_files()
468
466
command sed -e ' s/' " $_comp_cmd_scp__path_esc " ' /\\\\\\&/g' -e ' s/[*@|=]$//g' \
469
467
-e ' s/[^\/]$/& /g' )
470
468
fi
471
- COMPREPLY+=( $files )
469
+ _comp_split -la COMPREPLY " $files "
472
470
}
473
471
474
472
_comp_deprecate_func _scp_remote_files _comp_xfunc_ssh_scp_remote_files
@@ -487,12 +485,15 @@ _comp_xfunc_ssh_scp_local_files()
487
485
shift
488
486
fi
489
487
488
+ local files
489
+ _comp_expand_glob files ' "$cur"*'
490
+ (( ${# files[@]} )) || return 0
490
491
if $dirsonly ; then
491
- COMPREPLY+=($( command ls -aF1dL " $cur " * 2> /dev/null |
492
+ COMPREPLY+=($( command ls -aF1dL " ${files[@]} " 2> /dev/null |
492
493
command sed -e " s/$_comp_cmd_scp__path_esc /\\\\ &/g" -e ' /[^\/]$/d' \
493
494
-e " s/^/${1-} /" ) )
494
495
else
495
- COMPREPLY+=($( command ls -aF1dL " $cur " * 2> /dev/null |
496
+ COMPREPLY+=($( command ls -aF1dL " ${files[@]} " 2> /dev/null |
496
497
command sed -e " s/$_comp_cmd_scp__path_esc /\\\\ &/g" -e ' s/[*@|=]$//g' \
497
498
-e ' s/[^\/]$/& /g' -e " s/^/${1-} /" ) )
498
499
fi
0 commit comments