From 7c5840c46e3d0e7a12a6908970353c33f7dc0f88 Mon Sep 17 00:00:00 2001 From: Brent Yi Date: Fri, 9 Sep 2022 06:08:19 -0700 Subject: [PATCH] bash: fix subcommand completion --- shtab/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/shtab/__init__.py b/shtab/__init__.py index 87ca026..1d03c8a 100644 --- a/shtab/__init__.py +++ b/shtab/__init__.py @@ -353,7 +353,7 @@ def complete_bash(parser, root_prefix=None, preamble="", choice_functions=None): local current_action_compgen_var=${current_action}_COMPGEN current_action_compgen="${!current_action_compgen_var}" - local current_action_choices_var="${current_action}_choices" + local current_action_choices_var="${current_action}_choices[@]" current_action_choices="${!current_action_choices_var}" local current_action_nargs_var="${current_action}_nargs" @@ -421,8 +421,7 @@ def complete_bash(parser, root_prefix=None, preamble="", choice_functions=None): COMPREPLY=( $(compgen -W "${current_option_strings[*]}" -- "${completing_word}") ) else # use choices & compgen - local IFS=$'\\n' - COMPREPLY=( $(compgen -W "${current_action_choices}" -- "${completing_word}") \\ + COMPREPLY=( $(compgen -W "${current_action_choices[*]}" -- "${completing_word}") \\ $([ -n "${current_action_compgen}" ] \\ && "${current_action_compgen}" "${completing_word}") ) fi