@@ -98,8 +98,6 @@ _comp_userland()
98
98
[[ $userland == " $1 " ]]
99
99
}
100
100
101
- _comp_deprecate_func _userland _comp_userland
102
-
103
101
# This function sets correct SysV init directories
104
102
#
105
103
_comp_sysvdirs ()
@@ -112,8 +110,6 @@ _comp_sysvdirs()
112
110
return 0
113
111
}
114
112
115
- _comp_deprecate_func _sysvdirs _comp_sysvdirs
116
-
117
113
# This function checks whether we have a given program on the system.
118
114
#
119
115
_comp_have_command ()
@@ -123,18 +119,6 @@ _comp_have_command()
123
119
PATH=$PATH :/usr/sbin:/sbin:/usr/local/sbin type " $1 " & > /dev/null
124
120
}
125
121
126
- _comp_deprecate_func _have _comp_have_command
127
-
128
- # Backwards compatibility for compat completions that use have().
129
- # @deprecated should no longer be used; generally not needed with dynamically
130
- # loaded completions, and _comp_have_command is suitable for runtime use.
131
- # shellcheck disable=SC2317 # available at load time only
132
- have ()
133
- {
134
- unset -v have
135
- _comp_have_command " $1 " && have=yes
136
- }
137
-
138
122
# This function checks whether a given readline variable
139
123
# is `on'.
140
124
#
@@ -143,8 +127,6 @@ _comp_readline_variable_on()
143
127
[[ $( bind -v) == * $1 + ([[:space:]])on* ]]
144
128
}
145
129
146
- _comp_deprecate_func _rl_enabled _comp_readline_variable_on
147
-
148
130
# This function shell-quotes the argument
149
131
# @param $1 String to be quoted
150
132
# @var[out] ret Resulting string
@@ -153,15 +135,6 @@ _comp_quote()
153
135
ret=\' ${1// \' / \'\\\'\' } \'
154
136
}
155
137
156
- # This function shell-quotes the argument
157
- # @deprecated Use `_comp_quote` instead. Note that `_comp_quote` stores
158
- # the results in the variable `ret` instead of writing them to stdout.
159
- quote ()
160
- {
161
- local quoted=${1// \' / \'\\\'\' }
162
- printf " '%s'" " $quoted "
163
- }
164
-
165
138
# @see _quote_readline_by_ref()
166
139
quote_readline ()
167
140
{
@@ -231,18 +204,6 @@ _comp_dequote()
231
204
eval " ret=($1 )" 2> /dev/null # may produce failglob
232
205
}
233
206
234
- # This function shell-dequotes the argument
235
- # @deprecated Use `_comp_dequote' instead. Note that `_comp_dequote` stores
236
- # the results in the array `ret` instead of writing them to stdout.
237
- dequote ()
238
- {
239
- local ret
240
- _comp_dequote " $1 "
241
- local rc=$?
242
- printf %s " $ret "
243
- return $rc
244
- }
245
-
246
207
# Unset the given variables across a scope boundary. Useful for unshadowing
247
208
# global scoped variables. Note that simply calling unset on a local variable
248
209
# will not unshadow the global variable. Rather, the result will be a local
@@ -260,29 +221,6 @@ _comp_unlocal()
260
221
fi
261
222
}
262
223
263
- # Assign variable one scope above the caller
264
- # Usage: local "$1" && _upvar $1 "value(s)"
265
- # @param $1 Variable name to assign value to
266
- # @param $* Value(s) to assign. If multiple values, an array is
267
- # assigned, otherwise a single value is assigned.
268
- # NOTE: For assigning multiple variables, use '_upvars'. Do NOT
269
- # use multiple '_upvar' calls, since one '_upvar' call might
270
- # reassign a variable to be used by another '_upvar' call.
271
- # @see https://fvue.nl/wiki/Bash:_Passing_variables_by_reference
272
- _upvar ()
273
- {
274
- echo " bash_completion: $FUNCNAME : deprecated function," \
275
- " use _upvars instead" >&2
276
- if unset -v " $1 " ; then # Unset & validate varname
277
- # shellcheck disable=SC2140 # TODO
278
- if (( $# == 2 )) ; then
279
- eval " $1 " =\"\$ 2\" # Return single value
280
- else
281
- eval " $1 " =\(\"\$ " {@:2}" \"\) # Return array
282
- fi
283
- fi
284
- }
285
-
286
224
# Assign variables one scope above the caller
287
225
# Usage: local varname [varname ...] &&
288
226
# _upvars [-v varname value] | [-aN varname [value ...]] ...
@@ -648,66 +586,6 @@ _get_comp_words_by_ref()
648
586
(( ${# upvars[@]} )) && local " ${upvars[@]} " && _upvars " ${upargs[@]} "
649
587
}
650
588
651
- # Get the word to complete.
652
- # This is nicer than ${COMP_WORDS[COMP_CWORD]}, since it handles cases
653
- # where the user is completing in the middle of a word.
654
- # (For example, if the line is "ls foobar",
655
- # and the cursor is here --------> ^
656
- # @param $1 string Characters out of $COMP_WORDBREAKS which should NOT be
657
- # considered word breaks. This is useful for things like scp where
658
- # we want to return host:path and not only path, so we would pass the
659
- # colon (:) as $1 in this case.
660
- # @param $2 integer Index number of word to return, negatively offset to the
661
- # current word (default is 0, previous is 1), respecting the exclusions
662
- # given at $1. For example, `_get_cword "=:" 1' returns the word left of
663
- # the current word, respecting the exclusions "=:".
664
- # @deprecated Use `_get_comp_words_by_ref cur' instead
665
- # @see _get_comp_words_by_ref()
666
- _get_cword ()
667
- {
668
- local LC_CTYPE=C
669
- local cword words
670
- __reassemble_comp_words_by_ref " ${1-} " words cword
671
-
672
- # return previous word offset by $2
673
- if [[ ${2-} && ${2// [^0-9]/ } ]]; then
674
- printf " %s" " ${words[cword - $2]} "
675
- elif (( ${# words[cword]} == 0 && COMP_POINT == ${# COMP_LINE} )) ; then
676
- : # nothing
677
- else
678
- local i
679
- local cur=$COMP_LINE
680
- local index=$COMP_POINT
681
- for (( i = 0 ; i <= cword; ++ i)) ; do
682
- # Current word fits in $cur, and $cur doesn't match cword?
683
- while [[ ${# cur} -ge ${# words[i]} &&
684
- ${cur: 0: ${# words[i]} } != " ${words[i]} " ]]; do
685
- # Strip first character
686
- cur=${cur: 1}
687
- # Decrease cursor position, staying >= 0
688
- (( index > 0 )) && (( index-- ))
689
- done
690
-
691
- # Does found word match cword?
692
- if (( i < cword)) ; then
693
- # No, cword lies further;
694
- local old_size=${# cur}
695
- cur=${cur# " ${words[i]} " }
696
- local new_size=${# cur}
697
- (( index -= old_size - new_size))
698
- fi
699
- done
700
-
701
- if [[ ${words[cword]: 0: ${# cur} } != " $cur " ]]; then
702
- # We messed up! At least return the whole word so things
703
- # keep working
704
- printf " %s" " ${words[cword]} "
705
- else
706
- printf " %s" " ${cur: 0: index} "
707
- fi
708
- fi
709
- } # _get_cword()
710
-
711
589
# Get word previous to the current word.
712
590
# This is a good alternative to `prev=${COMP_WORDS[COMP_CWORD-1]}' because bash4
713
591
# will properly return the previous word with respect to any given exclusions to
@@ -1127,7 +1005,6 @@ _comp_initialize()
1127
1005
1128
1006
return 0
1129
1007
}
1130
- _comp_deprecate_func _init_completion _comp_initialize
1131
1008
1132
1009
# Helper function for _parse_help and _parse_usage.
1133
1010
# @return True (0) if an option was found, False (> 0) otherwise
@@ -1582,10 +1459,6 @@ _gids()
1582
1459
#
1583
1460
_comp_backup_glob= ' @(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))'
1584
1461
1585
- # @deprecated Use the variable `_comp_backup_glob` instead. This is the
1586
- # backward-compatibility name.
1587
- _backup_glob= $_comp_backup_glob
1588
-
1589
1462
# Complete on xinetd services
1590
1463
#
1591
1464
_xinetd_services ()
@@ -2387,7 +2260,6 @@ _comp_command_offset()
2387
2260
done
2388
2261
fi
2389
2262
}
2390
- _comp_deprecate_func _command_offset _comp_command_offset
2391
2263
2392
2264
# A _comp_command_offset wrapper function for use when the offset is unknown.
2393
2265
# Only intended to be used as a completion function directly associated
@@ -2407,7 +2279,6 @@ _comp_command()
2407
2279
done
2408
2280
_comp_command_offset $offset
2409
2281
}
2410
- _comp_deprecate_func _command _comp_command
2411
2282
complete -F _comp_command aoss command " do" else eval exec ltrace nice nohup padsp \
2412
2283
" then" time tsocks vsound xargs
2413
2284
@@ -2417,7 +2288,6 @@ _comp_root_command()
2417
2288
local root_command=$1
2418
2289
_comp_command
2419
2290
}
2420
- _comp_deprecate_func _root_command _comp_root_command
2421
2291
complete -F _comp_root_command fakeroot gksu gksudo kdesudo really
2422
2292
2423
2293
# Return true if the completion should be treated as running as root
@@ -2739,17 +2609,32 @@ _comp_xfunc()
2739
2609
" $xfunc_name " " ${@: 3} "
2740
2610
}
2741
2611
2742
- _comp_deprecate_func _xfunc _comp_xfunc
2743
-
2744
2612
# source compat completion directory definitions
2745
- _comp__init_compat_dir=${BASH_COMPLETION_COMPAT_DIR:-/ etc/ bash_completion.d}
2746
- if [[ -d $_comp__init_compat_dir && -r $_comp__init_compat_dir && -x $_comp__init_compat_dir ]]; then
2613
+ _comp__init_compat_dirs=()
2614
+ if [[ ${BASH_COMPLETION_COMPAT_DIR-} ]]; then
2615
+ _comp__init_compat_dirs+=(" $BASH_COMPLETION_COMPAT_DIR " )
2616
+ else
2617
+ _comp__init_compat_dirs+=(/etc/bash_completion.d)
2618
+ # Similarly as for the "completions" dir, look up from relative to
2619
+ # bash_completion, primarily for run-in-place-from-git-clone setups.
2620
+ # Notably we do it after the system location here, in order to
2621
+ # prefer in-tree variables and functions.
2622
+ if [[ $BASH_SOURCE == * /* ]]; then
2623
+ _comp__init_compat_dir=" ${BASH_SOURCE%/* } /bash_completion.d"
2624
+ [[ ${_comp__init_compat_dirs[0]} == " $_comp__init_compat_dir " ]] ||
2625
+ _comp__init_compat_dirs+=(" $_comp__init_compat_dir " )
2626
+ else
2627
+ _comp__init_compat_dirs+=(./bash_completion.d)
2628
+ fi
2629
+ fi
2630
+ for _comp__init_compat_dir in " ${_comp__init_compat_dirs[@]} " ; do
2631
+ [[ -d $_comp__init_compat_dir && -r $_comp__init_compat_dir && -x $_comp__init_compat_dir ]] || continue
2747
2632
for _comp__init_file in " $_comp__init_compat_dir " /* ; do
2748
2633
[[ ${_comp__init_file##*/ } != @ ($_comp_backup_glob | Makefile* | ${BASH_COMPLETION_COMPAT_IGNORE-} ) &&
2749
2634
-f $_comp__init_file && -r $_comp__init_file ]] && . " $_comp__init_file "
2750
2635
done
2751
- fi
2752
- unset -v _comp__init_compat_dir _comp__init_file
2636
+ done
2637
+ unset -v _comp__init_compat_dirs _comp__init_compat_dir _comp__init_file
2753
2638
2754
2639
# source user completion file
2755
2640
#
0 commit comments