Skip to content

Commit fb130ad

Browse files
committed
fix(gnokii): avoid non-POSIX ERE \b
The word-boundary anchor \b is not supported by POSIX Extended Regular Expressions (ERE). Also, the previous implementation did not consider the word-boyndary for the last element. We here explicitly match the trailing /[^_[:alnum:]]/ or /$/. Another issue is that the previous implementation did not work because of contaminated newlines in the ERE. We now split the results by newlines and then join the elements with IFS='|'.
1 parent 3a8a2ed commit fb130ad

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

completions/gnokii

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,14 @@ _comp_cmd_gnokii()
224224
local all_cmd="$(_parse_help "$1" "--help all")"
225225

226226
# these 2 below are allowed in combination with others
227-
local main_cmd=$(command sed -e '/--config/d;/--phone/d' <<<"$all_cmd")
227+
local main_cmd
228+
_comp_split -l main_cmd "$(command sed -e '/--config/d;/--phone/d' <<<"$all_cmd")"
228229
# don't provide main command completions if one is
229230
# already on the command line
230-
[[ $COMP_LINE =~ $(tr ' ' '\b|' <<<"$main_cmd") ]] && return
231+
local IFS='|'
232+
local regex_main_cmd="(${main_cmd[*]})($|[^_[:alnum:]])"
233+
IFS=$' \t\n'
234+
[[ $COMP_LINE =~ $regex_main_cmd ]] && return
231235

232236
COMPREPLY=($(compgen -W "$all_cmd" -- "$cur"))
233237
} &&

0 commit comments

Comments
 (0)