Skip to content

Commit

Permalink
[core/completion] Support scalar COMPREPLY with compgen -F
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 2, 2025
1 parent 1b10aa4 commit ab988fb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,16 @@ def Matches(self, comp):
self.func.name)
return

elif case(value_e.Str):
val = cast(value.Str, UP_val)
strs = [val.s]

elif case(value_e.BashArray):
val = cast(value.BashArray, UP_val)
strs = bash_impl.BashArray_GetValues(val)

else:
print_stderr('osh error: COMPREPLY should be an array, got %s' %
print_stderr('osh error: COMPREPLY should be an array or a string, got %s' %
ui.ValType(val))
return

Expand Down
13 changes: 13 additions & 0 deletions spec/builtin-completion.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -625,3 +625,16 @@ argv.py "${words[@]}"

## N-I bash STDOUT:
## END


#### compgen -F with scalar COMPREPLY

_comp_cmd_test() {
unset -v COMPREPLY
COMPREPLY=hello
}
compgen -F _comp_cmd_test

## STDOUT:
hello
## END

0 comments on commit ab988fb

Please sign in to comment.