@@ -513,32 +513,37 @@ _scp_remote_files()
513513# others. If first arg is -d, complete on directory names only. The next arg
514514# is an optional prefix to add to returned completions.
515515# @since 2.12
516- # TODO:API: make it a generator, don't append by default
517- _comp_xfunc_scp_local_files ()
516+ _comp_xfunc_scp_compgen_local_files ()
518517{
519- local IFS=$' \n '
520-
521- local dirsonly=" "
518+ local _dirsonly=" "
522519 if [[ ${1-} == -d ]]; then
523- dirsonly =set
520+ _dirsonly =set
524521 shift
525522 fi
526523
527524 local files
528525 _comp_expand_glob files ' "$cur"*'
529526 (( ${# files[@]} )) || return 0
530- if [[ $dirsonly ]]; then
531- COMPREPLY+=($( command ls -aF1dL " ${files[@]} " 2> /dev/null |
532- command sed -e " s/$_comp_cmd_scp__path_esc /\\\\ &/g" -e ' /[^\/]$/d' \
533- -e " s/^/${1-} /" ) )
527+ if [[ $_dirsonly ]]; then
528+ _comp_compgen -U files split -l -- " $(
529+ command ls -aF1dL " ${files[@]} " 2> /dev/null |
530+ command sed -e " s/$_comp_cmd_scp__path_esc /\\\\ &/g" \
531+ -e ' /[^\/]$/d' -e " s/^/${1-} /"
532+ ) "
534533 else
535- COMPREPLY+=($( command ls -aF1dL " ${files[@]} " 2> /dev/null |
536- command sed -e " s/$_comp_cmd_scp__path_esc /\\\\ &/g" -e ' s/[*@|=]$//g' \
537- -e ' s/[^\/]$/& /g' -e " s/^/${1-} /" ) )
534+ _comp_compgen -U files split -l -- " $(
535+ command ls -aF1dL " ${files[@]} " 2> /dev/null |
536+ command sed -e " s/$_comp_cmd_scp__path_esc /\\\\ &/g" \
537+ -e ' s/[*@|=]$//g' -e ' s/[^\/]$/& /g' -e " s/^/${1-} /"
538+ ) "
538539 fi
539540}
540541
541- _comp_deprecate_func 2.12 _scp_local_files _comp_xfunc_scp_local_files
542+ # @deprecated 2.12
543+ _scp_local_files ()
544+ {
545+ _comp_compgen -ax scp local_files " $@ "
546+ }
542547
543548# scp(1) completion
544549#
@@ -632,7 +637,7 @@ _comp_cmd_scp()
632637 esac
633638 fi
634639
635- _comp_xfunc_scp_local_files " ${prefix-} "
640+ _comp_compgen -ax scp local_files " ${prefix-} "
636641} &&
637642 complete -F _comp_cmd_scp -o nospace scp
638643
0 commit comments