__parse_options: Remove trailing [().]* from completions.

master
Ville Skyttä 2011-06-18 15:44:43 +03:00
parent 50a0506c5b
commit a52c4ea382
3 changed files with 7 additions and 4 deletions

View File

@ -703,12 +703,12 @@ __parse_options()
# Expand --[no]foo to --foo and --nofoo etc
if [[ $option =~ (\[((no|dont)-?)\]). ]]; then
option2=${option/"${BASH_REMATCH[1]}"/}
option2=${option2%%[<{[]*}
option2=${option2%%[<{().[]*}
printf '%s\n' "${option2/=*/=}"
option=${option/"${BASH_REMATCH[1]}"/"${BASH_REMATCH[2]}"}
fi
option=${option%%[<{[]*}
option=${option%%[<{().[]*}
printf '%s\n' "${option/=*/=}"
}

View File

@ -59,8 +59,7 @@ _mysql()
case $cur in
--*)
# TODO: fix _parse_help
local help=$(_parse_help "$1"|sed -e 's/[.)]*$//')
local help=$(_parse_help "$1")
help+=" --skip-comment --skip-ssl"
COMPREPLY=( $( compgen -W "$help" -- "$cur" ) )

View File

@ -121,5 +121,9 @@ set cmd {fn() { printf '%s\n' "-f [FOO], --foo[=FOO]"; }; _parse_help fn}
assert_bash_list "--foo" $cmd "-f \[FOO\], --foo\[=FOO\]"
sync_after_int
set cmd {fn() { printf '%s\n' "--foo."; }; _parse_help fn}
assert_bash_list "--foo" $cmd "--foo."
sync_after_int
teardown