Skip to content

Commit 9b70abe

Browse files
committed
refactor(_comp_deprecate_func): add version parameter
Making it the first one to make forgetting or faking it harder. #893
1 parent 00194dc commit 9b70abe

File tree

13 files changed

+52
-41
lines changed

13 files changed

+52
-41
lines changed

bash_completion

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,23 @@ fi
4141
shopt -s extglob progcomp
4242

4343
# Declare a compatibility function name
44-
# @param $1 Old function name
45-
# @param $2 New function name
44+
# @param $1 Version of bash-completion where the deprecation occurred
45+
# @param $2 Old function name
46+
# @param $3 New function name
4647
_comp_deprecate_func()
4748
{
48-
if [[ $1 != [a-zA-Z_]*([a-zA-Z_0-9]) ]]; then
49-
printf 'bash_completion: %s: %s\n' "$FUNCNAME" "\$1: invalid function name '$1'" >&2
49+
if (($# != 3)); then
50+
printf 'bash_completion: %s: usage: %s OLD_NAME NEW_NAME DEPRECATION_VERSION\n' "$FUNCNAME" "$FUNCNAME"
5051
return 2
51-
elif [[ $2 != [a-zA-Z_]*([a-zA-Z_0-9]) ]]; then
52-
printf 'bash_completion: %s: %s\n' "$FUNCNAME" "\$2: invalid function name '$2'" >&2
52+
fi
53+
if [[ $2 != [a-zA-Z_]*([a-zA-Z_0-9]) ]]; then
54+
printf 'bash_completion: %s: %s\n' "$FUNCNAME" "\$2: invalid function name '$1'" >&2
55+
return 2
56+
elif [[ $3 != [a-zA-Z_]*([a-zA-Z_0-9]) ]]; then
57+
printf 'bash_completion: %s: %s\n' "$FUNCNAME" "\$3: invalid function name '$2'" >&2
5358
return 2
5459
fi
55-
eval -- "$1() { $2 \"\$@\"; }"
60+
eval -- "$2() { $3 \"\$@\"; }"
5661
}
5762

5863
# A lot of the following one-liners were taken directly from the

bash_completion.d/000_bash_completion_compat.bash

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Deprecated bash_completion functions and variables -*- shell-script -*-
22

3-
_comp_deprecate_func _userland _comp_userland
4-
_comp_deprecate_func _sysvdirs _comp_sysvdirs
5-
_comp_deprecate_func _have _comp_have_command
6-
_comp_deprecate_func _rl_enabled _comp_readline_variable_on
7-
_comp_deprecate_func _command_offset _comp_command_offset
8-
_comp_deprecate_func _command _comp_command
9-
_comp_deprecate_func _root_command _comp_root_command
10-
_comp_deprecate_func _xfunc _comp_xfunc
11-
_comp_deprecate_func _upvars _comp_upvars
12-
_comp_deprecate_func __reassemble_comp_words_by_ref _comp__reassemble_words
13-
_comp_deprecate_func __get_cword_at_cursor_by_ref _comp__get_cword_at_cursor
14-
_comp_deprecate_func _get_comp_words_by_ref _comp_get_words
15-
_comp_deprecate_func _longopt _comp_longopt
16-
_comp_deprecate_func _split_longopt _comp__split_longopt
17-
_comp_deprecate_func __ltrim_colon_completions _comp_ltrim_colon_completions
3+
_comp_deprecate_func 2.12 _userland _comp_userland
4+
_comp_deprecate_func 2.12 _sysvdirs _comp_sysvdirs
5+
_comp_deprecate_func 2.12 _have _comp_have_command
6+
_comp_deprecate_func 2.12 _rl_enabled _comp_readline_variable_on
7+
_comp_deprecate_func 2.12 _command_offset _comp_command_offset
8+
_comp_deprecate_func 2.12 _command _comp_command
9+
_comp_deprecate_func 2.12 _root_command _comp_root_command
10+
_comp_deprecate_func 2.12 _xfunc _comp_xfunc
11+
_comp_deprecate_func 2.12 _upvars _comp_upvars
12+
_comp_deprecate_func 2.12 __reassemble_comp_words_by_ref _comp__reassemble_words
13+
_comp_deprecate_func 2.12 __get_cword_at_cursor_by_ref \
14+
_comp__get_cword_at_cursor
15+
_comp_deprecate_func 2.12 _get_comp_words_by_ref _comp_get_words
16+
_comp_deprecate_func 2.12 _longopt _comp_longopt
17+
_comp_deprecate_func 2.12 _split_longopt _comp__split_longopt
18+
_comp_deprecate_func 2.12 __ltrim_colon_completions _comp_ltrim_colon_completions
1819

1920
# Backwards compatibility for compat completions that use have().
2021
# @deprecated should no longer be used; generally not needed with dynamically

completions/apt-cache

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ _comp_xfunc_apt_cache_src_packages()
2525
compgen -W '$(_comp_xfunc_apt_cache_sources "$cur")' -- "$cur"
2626
}
2727

28-
_comp_deprecate_func _apt_cache_packages _comp_xfunc_apt_cache_packages
29-
_comp_deprecate_func _apt_cache_sources _comp_xfunc_apt_cache_sources
30-
_comp_deprecate_func _apt_cache_src_packages _comp_xfunc_apt_cache_src_packages
28+
_comp_deprecate_func 2.12 _apt_cache_packages _comp_xfunc_apt_cache_packages
29+
_comp_deprecate_func 2.12 _apt_cache_sources _comp_xfunc_apt_cache_sources
30+
_comp_deprecate_func 2.12 _apt_cache_src_packages \
31+
_comp_xfunc_apt_cache_src_packages
3132

3233
_comp_cmd_apt_cache()
3334
{

completions/apt-get

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ _comp_xfunc_apt_get_installed_packages()
1212
fi
1313
}
1414

15-
_comp_deprecate_func _comp_cmd_apt_get_installed_packages _comp_xfunc_apt_get_installed_packages
15+
_comp_deprecate_func 2.12 _comp_cmd_apt_get_installed_packages \
16+
_comp_xfunc_apt_get_installed_packages
1617

1718
_comp_cmd_apt_get()
1819
{

completions/asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ _comp_xfunc_asciidoc_doctype()
66
_comp_compgen -a -- -W 'article book manpage'
77
}
88

9-
_comp_deprecate_func _asciidoc_doctype _comp_xfunc_asciidoc_doctype
9+
_comp_deprecate_func 2.12 _asciidoc_doctype _comp_xfunc_asciidoc_doctype
1010

1111
_comp_cmd_asciidoc()
1212
{

completions/cvs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ _comp_xfunc_cvs_roots()
4848
_comp_ltrim_colon_completions "$cur"
4949
}
5050

51-
_comp_deprecate_func _cvs_roots _comp_xfunc_cvs_roots
51+
_comp_deprecate_func 2.12 _cvs_roots _comp_xfunc_cvs_roots
5252

5353
_comp_cmd_cvs()
5454
{

completions/iconv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _comp_xfunc_iconv_charsets()
77
command sed -e "s@/*\$@@" -e "s/[,()]//g")' -- "$cur"))
88
}
99

10-
_comp_deprecate_func _iconv_charsets _comp_xfunc_iconv_charsets
10+
_comp_deprecate_func 2.12 _iconv_charsets _comp_xfunc_iconv_charsets
1111

1212
_comp_cmd_iconv()
1313
{

completions/list_lists

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ _comp_xfunc_list_lists_mailman_lists()
66
COMPREPLY=($(compgen -W '$(list_lists -b 2>/dev/null)' -- "$cur"))
77
}
88

9-
_comp_deprecate_func _mailman_lists _comp_xfunc_list_lists_mailman_lists
9+
_comp_deprecate_func 2.12 _mailman_lists _comp_xfunc_list_lists_mailman_lists
1010

1111
_comp_cmd_list_lists()
1212
{

completions/mysql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ _comp_xfunc_mysql_character_sets()
1111
_comp_compgen -a -- -W '"${charsets[@]}"' -X ''
1212
}
1313

14-
_comp_deprecate_func _mysql_character_sets _comp_xfunc_mysql_character_sets
14+
_comp_deprecate_func 2.12 _mysql_character_sets _comp_xfunc_mysql_character_sets
1515

1616
_comp_cmd_mysql()
1717
{

completions/python

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ _comp_xfunc_python_warning_actions()
1515
${prefix:+-P "$prefix"}
1616
}
1717

18-
_comp_deprecate_func _python_modules _comp_xfunc_python_modules
19-
_comp_deprecate_func _python_warning_actions _comp_xfunc_python_warning_actions
18+
_comp_deprecate_func 2.12 _python_modules _comp_xfunc_python_modules
19+
_comp_deprecate_func 2.12 _python_warning_actions \
20+
_comp_xfunc_python_warning_actions
2021

2122
_comp_cmd_python()
2223
{

0 commit comments

Comments
 (0)