From 87c4e626f77a159a2ea17b35ed050cf5be3bf2b9 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Thu, 2 Jan 2025 21:21:57 +0900 Subject: [PATCH] [core/completion] Support scalar COMPREPLY with `compgen -F` --- core/completion.py | 4 ++++ spec/builtin-completion.test.sh | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/core/completion.py b/core/completion.py index 56c7322de..702c23a9d 100755 --- a/core/completion.py +++ b/core/completion.py @@ -631,6 +631,10 @@ 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) diff --git a/spec/builtin-completion.test.sh b/spec/builtin-completion.test.sh index bb7c24b90..504881136 100644 --- a/spec/builtin-completion.test.sh +++ b/spec/builtin-completion.test.sh @@ -594,3 +594,16 @@ bar compgen=0 complete=0 ## END + + +#### compgen -F with scalar COMPREPLY + +_comp_cmd_test() { + unset -v COMPREPLY + COMPREPLY=hello +} +compgen -F _comp_cmd_test + +## STDOUT: +hello +## END