Skip to content

Commit f8203d9

Browse files
authored
Merge pull request #106 from brentyi/fix/bash_subcommands
2 parents 13de419 + 9bfda44 commit f8203d9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

shtab/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def complete_bash(parser, root_prefix=None, preamble="", choice_functions=None):
352352
local current_action_compgen_var=${current_action}_COMPGEN
353353
current_action_compgen="${!current_action_compgen_var}"
354354
355-
local current_action_choices_var="${current_action}_choices"
355+
local current_action_choices_var="${current_action}_choices[@]"
356356
current_action_choices="${!current_action_choices_var}"
357357
358358
local current_action_nargs_var="${current_action}_nargs"
@@ -420,10 +420,11 @@ def complete_bash(parser, root_prefix=None, preamble="", choice_functions=None):
420420
COMPREPLY=( $(compgen -W "${current_option_strings[*]}" -- "${completing_word}") )
421421
else
422422
# use choices & compgen
423-
local IFS=$'\\n'
424-
COMPREPLY=( $(compgen -W "${current_action_choices}" -- "${completing_word}") \\
425-
$([ -n "${current_action_compgen}" ] \\
423+
local IFS=$'\\n' # items may contain spaces, so delimit using newline
424+
COMPREPLY=( $([ -n "${current_action_compgen}" ] \\
426425
&& "${current_action_compgen}" "${completing_word}") )
426+
unset IFS
427+
COMPREPLY+=( $(compgen -W "${current_action_choices[*]}" -- "${completing_word}") )
427428
fi
428429
429430
return 0

0 commit comments

Comments
 (0)