Skip to content

Commit dbd3e3d

Browse files
committed
completions-getter: Support complete actions with only options
This is actually supported even though we were ignoring it
1 parent 89e1970 commit dbd3e3d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

bash-completions-getter.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ get_completions() {
215215
echo -n "WORDS: " >&2; printf "'%s'," "${COMPLETE_WORDS[@]}" >&2; echo >&2
216216
fi
217217

218-
if [ ${#COMPLETE_WORDS[@]} -gt 0 ]; then
218+
if [ ${#COMPLETE_WORDS[@]} -gt 0 ] ||
219+
[ ${#COMPLETE_OPTIONS[@]} -gt 0 ]; then
219220
echo "${_COMP_OPTIONS[@]}"
220221
printf "%s\n" "${COMPLETE_WORDS[@]}"
221222
return 0

tests/test-bash-completions-getter.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ check_completion foo-with-multiple-options "foo" "nosort nospace"
115115
complete -o nospace -W "foo bar" -o nosort foo-with-multiple-words-and-options
116116
check_completion foo-with-multiple-words-and-options "foo bar" "nosort nospace"
117117

118-
complete -o nospace -o nosort foo-with-only-options
119-
expect_failure foo-with-only-options
118+
complete -o nospace -o nosort -o default foo-with-only-options
119+
check_completion foo-with-only-options '' "default nosort nospace"
120120

121121
complete -F foo_complete_function_not_existant foo-with-function-invalid
122122
expect_failure foo-with-function-invalid

0 commit comments

Comments
 (0)