Skip to content

Commit 67b2210

Browse files
authored
Merge pull request #946 from scop/refactor/longopt
refactor: longopt functions to new naming
2 parents ec49676 + 19a3798 commit 67b2210

File tree

9 files changed

+17
-14
lines changed

9 files changed

+17
-14
lines changed

bash_completion

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ _filedir()
797797
# this to be useful.
798798
# Returns 0 if current option was split, 1 otherwise.
799799
#
800-
_split_longopt()
800+
_comp__split_longopt()
801801
{
802802
if [[ $cur == --?*=* ]]; then
803803
# Cut also backslash before '=' in case it ended up there
@@ -977,7 +977,7 @@ _comp_variable_assignments()
977977
# -e XSPEC Passed to _filedir as first arg for stderr redirections
978978
# -o XSPEC Passed to _filedir as first arg for other output redirections
979979
# -i XSPEC Passed to _filedir as first arg for stdin redirections
980-
# -s Split long options with _split_longopt, implies -n =
980+
# -s Split long options with _comp__split_longopt, implies -n =
981981
# @param $1...$3 args Original arguments specified to the completion function.
982982
# The first argument $1 is command name. The second
983983
# argument $2 is the string before the cursor in the
@@ -1066,7 +1066,7 @@ _comp_initialize()
10661066
((cword <= 0)) && return 1
10671067
prev=${words[cword - 1]}
10681068

1069-
[[ $opt_split ]] && _split_longopt && was_split="set"
1069+
[[ $opt_split ]] && _comp__split_longopt && was_split="set"
10701070

10711071
return 0
10721072
}
@@ -2370,7 +2370,7 @@ _complete_as_root()
23702370
[[ $EUID -eq 0 || ${root_command-} ]]
23712371
}
23722372

2373-
_longopt()
2373+
_comp_longopt()
23742374
{
23752375
local cur prev words cword was_split comp_args
23762376
_comp_initialize -s -- "$@" || return
@@ -2420,7 +2420,8 @@ _longopt()
24202420
fi
24212421
}
24222422
# makeinfo and texi2dvi are defined elsewhere.
2423-
complete -F _longopt a2ps awk base64 bash bc bison cat chroot colordiff cp \
2423+
complete -F _comp_longopt \
2424+
a2ps awk base64 bash bc bison cat chroot colordiff cp \
24242425
csplit cut date df diff dir du enscript env expand fmt fold gperf \
24252426
grep grub head irb ld ldd less ln ls m4 mkdir mkfifo mknod \
24262427
mv netstat nl nm objcopy objdump od paste pr ptx readelf rm rmdir \

bash_completion.d/000_bash_completion_compat.bash

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ _comp_deprecate_func _upvars _comp_upvars
1212
_comp_deprecate_func __reassemble_comp_words_by_ref _comp__reassemble_words
1313
_comp_deprecate_func __get_cword_at_cursor_by_ref _comp__get_cword_at_cursor
1414
_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
1517

1618
# Backwards compatibility for compat completions that use have().
1719
# @deprecated should no longer be used; generally not needed with dynamically
@@ -188,7 +190,7 @@ _realcommand()
188190
# -e XSPEC Passed to _filedir as first arg for stderr redirections
189191
# -o XSPEC Passed to _filedir as first arg for other output redirections
190192
# -i XSPEC Passed to _filedir as first arg for stdin redirections
191-
# -s Split long options with _split_longopt, implies -n =
193+
# -s Split long options with _comp__split_longopt, implies -n =
192194
# @var[out] cur Reconstructed current word
193195
# @var[out] prev Reconstructed previous word
194196
# @var[out] words Reconstructed words

completions/_xm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ _comp_cmd_xm()
1515
local cur prev words cword comp_args
1616
_comp_initialize -- "$@" || return
1717

18-
# TODO: _split_longopt
18+
# TODO: split longopt
1919

2020
local args command commands options
2121

completions/abook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ _comp_cmd_abook()
1515

1616
case $cur in
1717
-*)
18-
_longopt "$@"
18+
_comp_longopt "$@"
1919
return
2020
;;
2121
esac

completions/pyvenv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _comp_cmd_pyvenv()
1414
[[ $was_split ]] && return
1515

1616
if [[ $cur == -* ]]; then
17-
_longopt "$@"
17+
_comp_longopt "$@"
1818
return
1919
fi
2020

completions/sha256sum

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _comp_cmd_sha256sum()
1414
[[ $was_split ]] && return
1515

1616
if [[ $cur == -* ]]; then
17-
_longopt "$@"
17+
_comp_longopt "$@"
1818
return
1919
fi
2020

doc/styleguide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ available in `COMPREPLY`.
8181
## `[[ $was_split ]] && return`
8282

8383
Should be used in completions using the `-s` flag of `_comp_initialize`,
84-
or other similar cases where `_split_longopt` has been invoked, after
84+
or other similar cases where `_comp__split_longopt` has been invoked, after
8585
`$prev` has been managed but before `$cur` is considered. If `$cur` of the
8686
form `--foo=bar` was split into `prev=--foo` and `cur=bar`, and the `$prev`
8787
block did not process the option argument completion, it makes sense to return

test/t/test_grep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_2(self, completion):
1111
"""
1212
Test --no-*dir isn't restricted to dirs only.
1313
14-
Not really a grep option, but tests _longopt.
14+
Not really a grep option, but tests _comp_longopt.
1515
"""
1616
assert completion == "foo foo.d/".split()
1717

test/t/unit/test_unit_longopt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class TestUnitLongopt:
1010
@pytest.fixture(scope="class")
1111
def functions(self, request, bash):
1212
assert_bash_exec(bash, "_grephelp() { cat _longopt/grep--help.txt; }")
13-
assert_bash_exec(bash, "complete -F _longopt _grephelp")
13+
assert_bash_exec(bash, "complete -F _comp_longopt _grephelp")
1414
assert_bash_exec(bash, "_various() { cat _longopt/various.txt; }")
15-
assert_bash_exec(bash, "complete -F _longopt _various")
15+
assert_bash_exec(bash, "complete -F _comp_longopt _various")
1616

1717
@pytest.mark.complete("_grephelp --")
1818
def test_1(self, functions, completion):

0 commit comments

Comments
 (0)