Skip to content

Commit a01e2b5

Browse files
authored
bump version, merge pull request #23 from iterative/devel
fix bash>=4.4 bad substitution
2 parents f5693b8 + af45175 commit a01e2b5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

shtab/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ def complete_bash(
303303
echo $1 | sed 's/-/_/g'
304304
}
305305
306+
# $1=COMP_WORDS[1]
307+
_shtab_replace_nonword() {
308+
echo "${1//[^[:word:]]/_}"
309+
}
310+
306311
# $1=COMP_WORDS[1]
307312
{root_prefix}_compgen_root_() {
308313
local args_gen="{root_prefix}_COMPGEN"
@@ -316,7 +321,7 @@ def complete_bash(
316321
317322
# $1=COMP_WORDS[1]
318323
{root_prefix}_compgen_command_() {
319-
local flags_list="{root_prefix}_$(_shtab_replace_hyphen $1)"
324+
local flags_list="{root_prefix}_$(_shtab_replace_nonword $1)"
320325
local args_gen="${flags_list}_COMPGEN"
321326
COMPREPLY=( $(compgen -W "${!flags_list}" -- "$word"; \
322327
[ -n "${!args_gen}" ] && ${!args_gen} "$word") )
@@ -325,8 +330,7 @@ def complete_bash(
325330
# $1=COMP_WORDS[1]
326331
# $2=COMP_WORDS[2]
327332
{root_prefix}_compgen_subcommand_() {
328-
local flags_list="{root_prefix}_$(\
329-
_shtab_replace_hyphen $1)_$(_shtab_replace_hyphen $2)"
333+
local flags_list="{root_prefix}_$(_shtab_replace_nonword "${1}_${2}")"
330334
local args_gen="${flags_list}_COMPGEN"
331335
[ -n "${!args_gen}" ] && local opts_more="$(${!args_gen} "$word")"
332336
local opts="${!flags_list}"

0 commit comments

Comments
 (0)