@@ -223,13 +223,13 @@ _comp_unlocal()
223
223
224
224
# Assign variables one scope above the caller
225
225
# Usage: local varname [varname ...] &&
226
- # _upvars [-v varname value] | [-aN varname [value ...]] ...
226
+ # _comp_upvars [-v varname value] | [-aN varname [value ...]] ...
227
227
# Available OPTIONS:
228
228
# -aN Assign next N values to varname as array
229
229
# -v Assign single value to varname
230
230
# @return 1 if error occurs
231
231
# @see https://fvue.nl/wiki/Bash:_Passing_variables_by_reference
232
- _upvars ()
232
+ _comp_upvars ()
233
233
{
234
234
if ! (( $# )) ; then
235
235
echo " bash_completion: $FUNCNAME : usage: $FUNCNAME " \
@@ -394,7 +394,7 @@ _comp_looks_like_path()
394
394
# @param $2 words Name of variable to return words to
395
395
# @param $3 cword Name of variable to return cword to
396
396
#
397
- __reassemble_comp_words_by_ref ()
397
+ _comp__reassemble_words ()
398
398
{
399
399
local exclude=" " i j line ref
400
400
# Exclude word separator characters?
@@ -454,7 +454,7 @@ __reassemble_comp_words_by_ref()
454
454
printf -v " $2 [i]" %s " ${COMP_WORDS[i]} "
455
455
done
456
456
fi
457
- } # __reassemble_comp_words_by_ref ()
457
+ } # _comp__reassemble_words ()
458
458
459
459
# @param $1 exclude Characters out of $COMP_WORDBREAKS which should NOT be
460
460
# considered word breaks. This is useful for things like scp where
@@ -463,11 +463,11 @@ __reassemble_comp_words_by_ref()
463
463
# @param $2 words Name of variable to return words to
464
464
# @param $3 cword Name of variable to return cword to
465
465
# @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 ()
468
468
{
469
469
local cword words=()
470
- __reassemble_comp_words_by_ref " $1 " words cword
470
+ _comp__reassemble_words " $1 " words cword
471
471
472
472
local i cur=" " index=$COMP_POINT lead=${COMP_LINE: 0: COMP_POINT}
473
473
# Cursor not at position 0 and not led by just space(s)?
@@ -498,7 +498,7 @@ __get_cword_at_cursor_by_ref()
498
498
(( index < 0 )) && index=0
499
499
fi
500
500
501
- local " $2 " " $3 " " $4 " && _upvars -a${# words[@]} " $2 " ${words+" ${words[@]} " } \
501
+ local " $2 " " $3 " " $4 " && _comp_upvars -a${# words[@]} " $2 " ${words+" ${words[@]} " } \
502
502
-v " $3 " " $cword " -v " $4 " " ${cur: 0: index} "
503
503
}
504
504
@@ -508,7 +508,7 @@ __get_cword_at_cursor_by_ref()
508
508
# (For example, if the line is "ls foobar",
509
509
# and the cursor is here --------> ^
510
510
# 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]
512
512
# Available VARNAMES:
513
513
# cur Return cur via $cur
514
514
# prev Return prev via $prev
@@ -527,9 +527,9 @@ __get_cword_at_cursor_by_ref()
527
527
#
528
528
# Example usage:
529
529
#
530
- # $ _get_comp_words_by_ref -n : cur prev
530
+ # $ _comp_get_words -n : cur prev
531
531
#
532
- _get_comp_words_by_ref ()
532
+ _comp_get_words ()
533
533
{
534
534
local exclude=" " flag i OPTIND=1
535
535
local cur cword words=()
@@ -569,7 +569,7 @@ _get_comp_words_by_ref()
569
569
(( OPTIND += 1 ))
570
570
done
571
571
572
- __get_cword_at_cursor_by_ref " ${exclude-} " words cword cur
572
+ _comp__get_cword_at_cursor " ${exclude-} " words cword cur
573
573
574
574
[[ $vcur ]] && {
575
575
upvars+=(" $vcur " )
@@ -588,21 +588,7 @@ _get_comp_words_by_ref()
588
588
upargs+=(-a${# words[@]} $vwords ${words+" ${words[@]} " } )
589
589
}
590
590
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[@]} "
606
592
}
607
593
608
594
# If the word-to-complete contains a colon (:), left-trim COMPREPLY items with
@@ -667,7 +653,7 @@ _quote_readline_by_ref()
667
653
value=${value// ' %' /%% } # Escape % for printf format.
668
654
# shellcheck disable=SC2059
669
655
printf -v value " $value " # Decode escape sequences of \....
670
- local " $2 " && _upvars -v " $2 " " $value "
656
+ local " $2 " && _comp_upvars -v " $2 " " $value "
671
657
fi
672
658
fi
673
659
} # _quote_readline_by_ref()
@@ -914,7 +900,7 @@ _comp_variable_assignments()
914
900
# cur, prev, words, and cword are local, ditto split if you use -s.
915
901
#
916
902
# 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
918
904
# -e XSPEC Passed to _filedir as first arg for stderr redirections
919
905
# -o XSPEC Passed to _filedir as first arg for other output redirections
920
906
# -i XSPEC Passed to _filedir as first arg for stdin redirections
@@ -962,7 +948,7 @@ _comp_initialize()
962
948
963
949
COMPREPLY=()
964
950
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
966
952
967
953
# Complete variable names.
968
954
_variables && return 1
@@ -1701,7 +1687,7 @@ _realcommand()
1701
1687
1702
1688
# This function returns the first argument, excluding options
1703
1689
# @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 .
1705
1691
_get_first_arg ()
1706
1692
{
1707
1693
local i
@@ -1717,13 +1703,13 @@ _get_first_arg()
1717
1703
1718
1704
# This function counts the number of args, excluding options
1719
1705
# @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 .
1721
1707
# @param $2 glob Options whose following argument should not be counted
1722
1708
# @param $3 glob Options that should be counted as args
1723
1709
_count_args ()
1724
1710
{
1725
1711
local i cword words
1726
- __reassemble_comp_words_by_ref " ${1-} " words cword
1712
+ _comp__reassemble_words " ${1-} " words cword
1727
1713
1728
1714
args=1
1729
1715
for (( i = 1 ; i < cword; i++ )) ; do
@@ -2188,7 +2174,7 @@ _comp_command_offset()
2188
2174
2189
2175
COMPREPLY=()
2190
2176
local cur
2191
- _get_comp_words_by_ref cur
2177
+ _comp_get_words cur
2192
2178
2193
2179
if (( COMP_CWORD == 0 )) ; then
2194
2180
local IFS=$' \n '
0 commit comments