Skip to content

Commit a112c25

Browse files
committed
bash-completions-getter: Return with error if completion command failed
1 parent 79be865 commit a112c25

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

bash-completions-getter.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ get_completions() {
250250
if [ "$COMPLETE_CALL_TYPE" == 'C' ]; then
251251
export COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS COMP_WORDBREAKS
252252
mapfile -t COMPREPLY < <("${cmd[@]}" 2>"$errorout")
253-
else
254-
"${cmd[@]}" 2>"$errorout"
253+
elif ! "${cmd[@]}" 2>"$errorout"; then
254+
return 1
255255
fi
256256

257257
[ ${#COMPLETE_WORDS[@]} -gt 0 ] &&

tests/test-bash-completions-getter.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ check_completion foo-with-multiple-words "foo --bar"
109109
complete -o nospace -W "foo" foo-with-word-and-option
110110
check_completion foo-with-word-and-option "foo" nospace
111111

112+
complete -F foo_complete_function_not_existant foo-with-function-invalid
113+
expect_failure foo-with-function-invalid
114+
112115
function foo_complete_function_simple() {
113116
EXPECTED_COMPLETE_PROGRAM=foo-with-function-simple
114117
EXPECTED_COMPLETE_WORD="''"

0 commit comments

Comments
 (0)