Skip to content

Commit fa8df33

Browse files
committed
fix(dpkg): don't offer broken option completions ending with "-"
1 parent b76b16d commit fa8df33

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

completions/dpkg

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ _dpkg()
8787
$split && return
8888

8989
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
90+
for i in ${!COMPREPLY[*]}; do
91+
# remove ones ending with a dash (known parse issue, hard to fix)
92+
[[ ${COMPREPLY[i]} != *- ]] || unset 'COMPREPLY[i]'
93+
done
9094
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
9195
} &&
9296
complete -F _dpkg dpkg dpkg-deb dpkg-query

test/t/test_dpkg.py

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ def test_3(self, completion):
1717
@pytest.mark.complete("dpkg -i dpkg/")
1818
def test_i_deb(self, completion):
1919
assert completion == "bash-completion-test-subject.deb"
20+
21+
@pytest.mark.complete("dpkg -")
22+
def test_no_trailing_dash_options(self, completion):
23+
assert not any(x.endswith("-") for x in completion)

0 commit comments

Comments
 (0)