Skip to content

Commit 0618236

Browse files
committed
docs(compat): add more @since and @deprecated versions, some TODOs
1 parent 5de5e74 commit 0618236

File tree

2 files changed

+45
-25
lines changed

2 files changed

+45
-25
lines changed

bash_completion

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ complete -b builtin
9696

9797
# Check if we're running on the given userland
9898
# @param $1 userland to check for
99+
# @since 2.12
99100
_comp_userland()
100101
{
101102
local userland=$(uname -s)
@@ -105,6 +106,7 @@ _comp_userland()
105106

106107
# This function sets correct SysV init directories
107108
#
109+
# @since 2.12
108110
_comp_sysvdirs()
109111
{
110112
sysvdirs=()
@@ -117,6 +119,7 @@ _comp_sysvdirs()
117119

118120
# This function checks whether we have a given program on the system.
119121
#
122+
# @since 2.12
120123
_comp_have_command()
121124
{
122125
# Completions for system administrator commands are installed as well in
@@ -127,6 +130,7 @@ _comp_have_command()
127130
# This function checks whether a given readline variable
128131
# is `on'.
129132
#
133+
# @since 2.12
130134
_comp_readline_variable_on()
131135
{
132136
[[ $(bind -v) == *$1+([[:space:]])on* ]]
@@ -135,6 +139,7 @@ _comp_readline_variable_on()
135139
# This function shell-quotes the argument
136140
# @param $1 String to be quoted
137141
# @var[out] ret Resulting string
142+
# @since 2.12
138143
_comp_quote()
139144
{
140145
ret=\'${1//\'/\'\\\'\'}\'
@@ -194,6 +199,7 @@ _comp_dequote__initialize
194199
# We allow these parameter expansions as a part of safe strings assuming the
195200
# referential transparency of the simple parameter expansions and the sane
196201
# setup of the variables by the user or other frameworks that the user loads.
202+
# @since 2.12
197203
_comp_dequote()
198204
{
199205
ret=() # fallback value for unsafe word and failglob
@@ -226,6 +232,7 @@ _comp_unlocal()
226232
# -v Assign single value to varname
227233
# @return 1 if error occurs
228234
# @see https://fvue.nl/wiki/Bash:_Passing_variables_by_reference
235+
# @since 2.12
229236
_comp_upvars()
230237
{
231238
if ! (($#)); then
@@ -467,6 +474,7 @@ _comp_split()
467474
# supposed to replace the existing content of the array by default to allow the
468475
# caller control whether to replace or append by the option `-a`.
469476
#
477+
# @since 2.12
470478
_comp_compgen()
471479
{
472480
local _append=${_comp_compgen__append-}
@@ -722,6 +730,7 @@ _comp__get_cword_at_cursor()
722730
#
723731
# $ _comp_get_words -n : cur prev
724732
#
733+
# @since 2.12
725734
_comp_get_words()
726735
{
727736
local exclude="" flag i OPTIND=1
@@ -801,6 +810,7 @@ _comp_get_words()
801810
# @param $1 current word to complete (cur)
802811
# @modifies global array $COMPREPLY
803812
#
813+
# @since 2.12
804814
_comp_ltrim_colon_completions()
805815
{
806816
local i=${#COMPREPLY[*]}
@@ -830,6 +840,7 @@ _comp_ltrim_colon_completions()
830840
# - https://www.mail-archive.com/bash-completion-devel@lists.alioth.debian.org/msg01944.html
831841
# @param $1 Argument to quote
832842
# @var[out] ret Quoted result is stored in this variable
843+
# @since 2.12
833844
# shellcheck disable=SC2178 # The assignment is not intended for the global "ret"
834845
_comp_quote_compgen()
835846
{
@@ -1118,6 +1129,7 @@ _comp_variable_assignments()
11181129
# @return True (0) if completion needs further processing,
11191130
# False (> 0) no further processing is necessary.
11201131
#
1132+
# @since 2.12
11211133
_comp_initialize()
11221134
{
11231135
local exclude="" opt_split="" outx errx inx
@@ -1285,6 +1297,7 @@ _comp_compgen_help__parse()
12851297
# When no arguments are specified, `--help` is assumed.
12861298
#
12871299
# @var[in] comp_args[0]
1300+
# @since 2.12
12881301
_comp_compgen_help()
12891302
{
12901303
(($#)) || set -- -- --help
@@ -1316,6 +1329,7 @@ _comp_compgen_help()
13161329
# When no arguments are specified, `--usage` is assumed.
13171330
#
13181331
# @var[in] comp_args[0]
1332+
# @since 2.12
13191333
_comp_compgen_usage()
13201334
{
13211335
(($#)) || set -- -- --usage
@@ -1921,6 +1935,7 @@ _comp_abspath()
19211935
# @param $1 Command
19221936
# @var[out] ret Resulting string
19231937
# @return True (0) if command found, False (> 0) if not.
1938+
# @since 2.12
19241939
_comp_realcommand()
19251940
{
19261941
ret=""
@@ -2372,6 +2387,7 @@ _comp__find_original_word()
23722387
# first complete on a command, then complete according to that command's own
23732388
# completion definition.
23742389
#
2390+
# @since 2.12
23752391
_comp_command_offset()
23762392
{
23772393
# rewrite current completion context before invoking
@@ -2489,6 +2505,7 @@ _comp_command_offset()
24892505
# Only intended to be used as a completion function directly associated
24902506
# with a command, not to be invoked from within other completion functions.
24912507
#
2508+
# @since 2.12
24922509
_comp_command()
24932510
{
24942511
# We unset the shell variable `words` locally to tell
@@ -2512,6 +2529,7 @@ _comp_command()
25122529
complete -F _comp_command aoss command "do" else eval exec ltrace nice nohup padsp \
25132530
"then" time tsocks vsound xargs
25142531

2532+
# @since 2.12
25152533
_comp_root_command()
25162534
{
25172535
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
@@ -2527,6 +2545,7 @@ _complete_as_root()
25272545
[[ $EUID -eq 0 || ${root_command-} ]]
25282546
}
25292547

2548+
# @since 2.12
25302549
_comp_longopt()
25312550
{
25322551
local cur prev words cword was_split comp_args
@@ -2846,6 +2865,7 @@ _completion_loader()
28462865
# `_comp_xfunc_${1//[^a-zA-Z0-9_]/_}_$2' is used for the actual name of the
28472866
# shell function.
28482867
# @param $3... if any, specifies the arguments that are passed to the xfunc.
2868+
# @since 2.12
28492869
_comp_xfunc()
28502870
{
28512871
local xfunc_name=$2

bash_completion.d/000_bash_completion_compat.bash

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ _comp_deprecate_func 2.12 _split_longopt _comp__split_longopt
1818
_comp_deprecate_func 2.12 __ltrim_colon_completions _comp_ltrim_colon_completions
1919

2020
# Backwards compatibility for compat completions that use have().
21-
# @deprecated should no longer be used; generally not needed with dynamically
22-
# loaded completions, and _comp_have_command is suitable for
23-
# runtime use.
21+
# @deprecated 1.90 should no longer be used; generally not needed with
22+
# dynamically loaded completions, and _comp_have_command is suitable for
23+
# runtime use.
2424
# shellcheck disable=SC2317 # available at load time only
2525
have()
2626
{
@@ -29,15 +29,15 @@ have()
2929
}
3030

3131
# This function shell-quotes the argument
32-
# @deprecated Use `_comp_quote` instead. Note that `_comp_quote` stores
32+
# @deprecated 2.12 Use `_comp_quote` instead. Note that `_comp_quote` stores
3333
# the results in the variable `ret` instead of writing them to stdout.
3434
quote()
3535
{
3636
local quoted=${1//\'/\'\\\'\'}
3737
printf "'%s'" "$quoted"
3838
}
3939

40-
# @deprecated Use `_comp_quote_compgen`
40+
# @deprecated 2.12 Use `_comp_quote_compgen`
4141
quote_readline()
4242
{
4343
local ret
@@ -49,7 +49,7 @@ quote_readline()
4949
# argument specifying the variable name to store the result.
5050
# @param $1 Argument to quote
5151
# @param $2 Name of variable to return result to
52-
# @deprecated Use `_comp_quote_compgen "$1"` instead. Note that
52+
# @deprecated 2.12 Use `_comp_quote_compgen "$1"` instead. Note that
5353
# `_comp_quote_compgen` stores the result in a fixed variable `ret`.
5454
_quote_readline_by_ref()
5555
{
@@ -59,8 +59,8 @@ _quote_readline_by_ref()
5959
}
6060

6161
# This function shell-dequotes the argument
62-
# @deprecated Use `_comp_dequote' instead. Note that `_comp_dequote` stores
63-
# the results in the array `ret` instead of writing them to stdout.
62+
# @deprecated 2.12 Use `_comp_dequote' instead. Note that `_comp_dequote`
63+
# stores the results in the array `ret` instead of writing them to stdout.
6464
dequote()
6565
{
6666
local ret
@@ -79,7 +79,7 @@ dequote()
7979
# use multiple '_upvar' calls, since one '_upvar' call might
8080
# reassign a variable to be used by another '_upvar' call.
8181
# @see https://fvue.nl/wiki/Bash:_Passing_variables_by_reference
82-
# @deprecated Use `_comp_upvars' instead
82+
# @deprecated 2.10 Use `_comp_upvars' instead
8383
_upvar()
8484
{
8585
echo "bash_completion: $FUNCNAME: deprecated function," \
@@ -107,7 +107,7 @@ _upvar()
107107
# current word (default is 0, previous is 1), respecting the exclusions
108108
# given at $1. For example, `_get_cword "=:" 1' returns the word left of
109109
# the current word, respecting the exclusions "=:".
110-
# @deprecated Use `_comp_get_words cur' instead
110+
# @deprecated TODO Use `_comp_get_words cur' instead
111111
# @see _comp_get_words()
112112
_get_cword()
113113
{
@@ -158,7 +158,7 @@ _get_cword()
158158
# This is a good alternative to `prev=${COMP_WORDS[COMP_CWORD-1]}' because bash4
159159
# will properly return the previous word with respect to any given exclusions to
160160
# COMP_WORDBREAKS.
161-
# @deprecated Use `_comp_get_words cur prev' instead
161+
# @deprecated TODO Use `_comp_get_words cur prev' instead
162162
# @see _comp_get_words()
163163
#
164164
_get_pword()
@@ -169,7 +169,7 @@ _get_pword()
169169
}
170170

171171
# Get real command.
172-
# @deprecated Use `_comp_realcommand` instead.
172+
# @deprecated 2.12 Use `_comp_realcommand` instead.
173173
# Note that `_comp_realcommand` stores the result in the variable `ret`
174174
# instead of writing it to stdout.
175175
_realcommand()
@@ -202,7 +202,7 @@ _realcommand()
202202
# @return True (0) if completion needs further processing,
203203
# False (> 0) no further processing is necessary.
204204
#
205-
# @deprecated Use the new interface `_comp_initialize`. The new interface
205+
# @deprecated 2.12 Use the new interface `_comp_initialize`. The new interface
206206
# supports the same set of options. The new interface receives additional
207207
# arguments $1 (command name), $2 (part of current word before the cursor), and
208208
# $3 (previous word) that are specified to the completion function by Bash.
@@ -234,21 +234,21 @@ _init_completion()
234234
return "$rc"
235235
}
236236

237-
# @deprecated Use the variable `_comp_backup_glob` instead. This is the
237+
# @deprecated 2.12 Use the variable `_comp_backup_glob` instead. This is the
238238
# backward-compatibility name.
239239
# shellcheck disable=SC2154 # defined in the main "bash_completion"
240240
_backup_glob=$_comp_backup_glob
241241

242-
# @deprecated use `_comp_cmd_cd` instead.
242+
# @deprecated 2.12 use `_comp_cmd_cd` instead.
243243
_cd()
244244
{
245245
declare -F _comp_cmd_cd &>/dev/null || __load_completion cd
246246
_comp_cmd_cd "$@"
247247
}
248248

249-
# @deprecated Use `_comp_command_offset` instead. Note that the new interface
250-
# `_comp_command_offset` is changed to receive an index in `words` instead of
251-
# that in `COMP_WORDS` as `_command_offset` did.
249+
# @deprecated 2.12 Use `_comp_command_offset` instead. Note that the new
250+
# interface `_comp_command_offset` is changed to receive an index in
251+
# `words` instead of that in `COMP_WORDS` as `_command_offset` did.
252252
_command_offset()
253253
{
254254
# We unset the shell variable `words` locally to tell
@@ -259,7 +259,7 @@ _command_offset()
259259
_comp_command_offset "$@"
260260
}
261261

262-
# @deprecated Use `_comp_compgen -a filedir`
262+
# @deprecated 2.12 Use `_comp_compgen -a filedir`
263263
_filedir()
264264
{
265265
_comp_compgen -a filedir "$@"
@@ -269,17 +269,17 @@ _filedir()
269269
# @return True (0) if completion needs further processing,
270270
# False (1) if tilde is followed by a valid username, completions are
271271
# put in COMPREPLY and no further processing is necessary.
272-
# @deprecated Use `_comp_compgen -c CUR tilde [-d]`. Note that the exit status
273-
# of `_comp_compgen_tilde` is flipped. It returns 0 when the tilde completions
274-
# are attempted, or otherwise 1.
272+
# @deprecated 2.12 Use `_comp_compgen -c CUR tilde [-d]`. Note that the exit
273+
# status of `_comp_compgen_tilde` is flipped. It returns 0 when the tilde
274+
# completions are attempted, or otherwise 1.
275275
_tilde()
276276
{
277277
! _comp_compgen -c "$1" tilde
278278
}
279279

280280
# Helper function for _parse_help and _parse_usage.
281281
# @return True (0) if an option was found, False (> 0) otherwise
282-
# @deprecated Use _comp_compgen_help__parse
282+
# @deprecated 2.12 Use _comp_compgen_help__parse
283283
__parse_options()
284284
{
285285
local -a _options=()
@@ -290,7 +290,7 @@ __parse_options()
290290
# Parse GNU style help output of the given command.
291291
# @param $1 command; if "-", read from stdin and ignore rest of args
292292
# @param $2 command options (default: --help)
293-
# @deprecated Use `_comp_compgen_help`. `COMPREPLY=($(compgen -W
293+
# @deprecated 2.12 Use `_comp_compgen_help`. `COMPREPLY=($(compgen -W
294294
# '$(_parse_help "$1" ...)' -- "$cur"))` can be replaced with
295295
# `_comp_compgen_help [-- ...]`. Also, `var=($(_parse_help "$1" ...))` can
296296
# be replaced with `_comp_compgen -Rv var help [-- ...]`.
@@ -314,7 +314,7 @@ _parse_help()
314314
# Parse BSD style usage output (options in brackets) of the given command.
315315
# @param $1 command; if "-", read from stdin and ignore rest of args
316316
# @param $2 command options (default: --usage)
317-
# @deprecated Use `_comp_compgen_usage`. `COMPREPLY=($(compgen -W
317+
# @deprecated 2.12 Use `_comp_compgen_usage`. `COMPREPLY=($(compgen -W
318318
# '$(_parse_usage "$1" ...)' -- "$cur"))` can be replaced with
319319
# `_comp_compgen_usage [-- ...]`. `var=($(_parse_usage "$1" ...))` can be
320320
# replaced with `_comp_compgen -Rv var usage [-- ...]`.

0 commit comments

Comments
 (0)