@@ -223,13 +223,13 @@ _comp_unlocal()
223223
224224# Assign variables one scope above the caller
225225# Usage: local varname [varname ...] &&
226- # _upvars [-v varname value] | [-aN varname [value ...]] ...
226+ # _comp_upvars [-v varname value] | [-aN varname [value ...]] ...
227227# Available OPTIONS:
228228# -aN Assign next N values to varname as array
229229# -v Assign single value to varname
230230# @return 1 if error occurs
231231# @see https://fvue.nl/wiki/Bash:_Passing_variables_by_reference
232- _upvars ()
232+ _comp_upvars ()
233233{
234234 if ! (( $# )) ; then
235235 echo " bash_completion: $FUNCNAME : usage: $FUNCNAME " \
@@ -394,7 +394,7 @@ _comp_looks_like_path()
394394# @param $2 words Name of variable to return words to
395395# @param $3 cword Name of variable to return cword to
396396#
397- __reassemble_comp_words_by_ref ()
397+ _comp__reassemble_words ()
398398{
399399 local exclude=" " i j line ref
400400 # Exclude word separator characters?
@@ -454,7 +454,7 @@ __reassemble_comp_words_by_ref()
454454 printf -v " $2 [i]" %s " ${COMP_WORDS[i]} "
455455 done
456456 fi
457- } # __reassemble_comp_words_by_ref ()
457+ } # _comp__reassemble_words ()
458458
459459# @param $1 exclude Characters out of $COMP_WORDBREAKS which should NOT be
460460# considered word breaks. This is useful for things like scp where
@@ -463,11 +463,11 @@ __reassemble_comp_words_by_ref()
463463# @param $2 words Name of variable to return words to
464464# @param $3 cword Name of variable to return cword to
465465# @param $4 cur Name of variable to return current word to complete to
466- # @see __reassemble_comp_words_by_ref ()
467- __get_cword_at_cursor_by_ref ()
466+ # @see _comp__reassemble_words ()
467+ _comp__get_cword_at_cursor ()
468468{
469469 local cword words=()
470- __reassemble_comp_words_by_ref " $1 " words cword
470+ _comp__reassemble_words " $1 " words cword
471471
472472 local i cur=" " index=$COMP_POINT lead=${COMP_LINE: 0: COMP_POINT}
473473 # Cursor not at position 0 and not led by just space(s)?
@@ -498,7 +498,7 @@ __get_cword_at_cursor_by_ref()
498498 (( index < 0 )) && index=0
499499 fi
500500
501- local " $2 " " $3 " " $4 " && _upvars -a${# words[@]} " $2 " ${words+" ${words[@]} " } \
501+ local " $2 " " $3 " " $4 " && _comp_upvars -a${# words[@]} " $2 " ${words+" ${words[@]} " } \
502502 -v " $3 " " $cword " -v " $4 " " ${cur: 0: index} "
503503}
504504
@@ -508,7 +508,7 @@ __get_cword_at_cursor_by_ref()
508508# (For example, if the line is "ls foobar",
509509# and the cursor is here --------> ^
510510# Also one is able to cross over possible wordbreak characters.
511- # Usage: _get_comp_words_by_ref [OPTIONS] [VARNAMES]
511+ # Usage: _comp_get_words [OPTIONS] [VARNAMES]
512512# Available VARNAMES:
513513# cur Return cur via $cur
514514# prev Return prev via $prev
@@ -527,9 +527,9 @@ __get_cword_at_cursor_by_ref()
527527#
528528# Example usage:
529529#
530- # $ _get_comp_words_by_ref -n : cur prev
530+ # $ _comp_get_words -n : cur prev
531531#
532- _get_comp_words_by_ref ()
532+ _comp_get_words ()
533533{
534534 local exclude=" " flag i OPTIND=1
535535 local cur cword words=()
@@ -569,7 +569,7 @@ _get_comp_words_by_ref()
569569 (( OPTIND += 1 ))
570570 done
571571
572- __get_cword_at_cursor_by_ref " ${exclude-} " words cword cur
572+ _comp__get_cword_at_cursor " ${exclude-} " words cword cur
573573
574574 [[ $vcur ]] && {
575575 upvars+=(" $vcur " )
@@ -588,21 +588,7 @@ _get_comp_words_by_ref()
588588 upargs+=(-a${# words[@]} $vwords ${words+" ${words[@]} " } )
589589 }
590590
591- (( ${# upvars[@]} )) && local " ${upvars[@]} " && _upvars " ${upargs[@]} "
592- }
593-
594- # Get word previous to the current word.
595- # This is a good alternative to `prev=${COMP_WORDS[COMP_CWORD-1]}' because bash4
596- # will properly return the previous word with respect to any given exclusions to
597- # COMP_WORDBREAKS.
598- # @deprecated Use `_get_comp_words_by_ref cur prev' instead
599- # @see _get_comp_words_by_ref()
600- #
601- _get_pword ()
602- {
603- if (( COMP_CWORD >= 1 )) ; then
604- _get_cword " ${@ -} " 1
605- fi
591+ (( ${# upvars[@]} )) && local " ${upvars[@]} " && _comp_upvars " ${upargs[@]} "
606592}
607593
608594# If the word-to-complete contains a colon (:), left-trim COMPREPLY items with
@@ -667,7 +653,7 @@ _quote_readline_by_ref()
667653 value=${value// ' %' /%% } # Escape % for printf format.
668654 # shellcheck disable=SC2059
669655 printf -v value " $value " # Decode escape sequences of \....
670- local " $2 " && _upvars -v " $2 " " $value "
656+ local " $2 " && _comp_upvars -v " $2 " " $value "
671657 fi
672658 fi
673659} # _quote_readline_by_ref()
@@ -914,7 +900,7 @@ _comp_variable_assignments()
914900# cur, prev, words, and cword are local, ditto split if you use -s.
915901#
916902# Options:
917- # -n EXCLUDE Passed to _get_comp_words_by_ref -n with redirection chars
903+ # -n EXCLUDE Passed to _comp_get_words -n with redirection chars
918904# -e XSPEC Passed to _filedir as first arg for stderr redirections
919905# -o XSPEC Passed to _filedir as first arg for other output redirections
920906# -i XSPEC Passed to _filedir as first arg for stdin redirections
@@ -962,7 +948,7 @@ _comp_initialize()
962948
963949 COMPREPLY=()
964950 local redir=' @(?(+([0-9])|{[a-zA-Z_]*([a-zA-Z_0-9])})@(>?([>|&])|<?([>&])|<<?([-<]))|&>?(>))'
965- _get_comp_words_by_ref -n " $exclude <>&" cur prev words cword
951+ _comp_get_words -n " $exclude <>&" cur prev words cword
966952
967953 # Complete variable names.
968954 _variables && return 1
@@ -1701,7 +1687,7 @@ _realcommand()
17011687
17021688# This function returns the first argument, excluding options
17031689# @param $1 chars Characters out of $COMP_WORDBREAKS which should
1704- # NOT be considered word breaks. See __reassemble_comp_words_by_ref .
1690+ # NOT be considered word breaks. See _comp__reassemble_words .
17051691_get_first_arg ()
17061692{
17071693 local i
@@ -1717,13 +1703,13 @@ _get_first_arg()
17171703
17181704# This function counts the number of args, excluding options
17191705# @param $1 chars Characters out of $COMP_WORDBREAKS which should
1720- # NOT be considered word breaks. See __reassemble_comp_words_by_ref .
1706+ # NOT be considered word breaks. See _comp__reassemble_words .
17211707# @param $2 glob Options whose following argument should not be counted
17221708# @param $3 glob Options that should be counted as args
17231709_count_args ()
17241710{
17251711 local i cword words
1726- __reassemble_comp_words_by_ref " ${1-} " words cword
1712+ _comp__reassemble_words " ${1-} " words cword
17271713
17281714 args=1
17291715 for (( i = 1 ; i < cword; i++ )) ; do
@@ -2188,7 +2174,7 @@ _comp_command_offset()
21882174
21892175 COMPREPLY=()
21902176 local cur
2191- _get_comp_words_by_ref cur
2177+ _comp_get_words cur
21922178
21932179 if (( COMP_CWORD == 0 )) ; then
21942180 local IFS=$' \n '
0 commit comments