diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2011-06-18 15:44:43 +0300 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2011-06-18 15:44:43 +0300 |
commit | a52c4ea382814cb958cfd432d04ce6fc9f09a84f (patch) | |
tree | 4aab27b16ee9bfff814b2763f69a0f9aa96687d9 | |
parent | 50a0506c5bf3e7873485ec595c59a4d7e80968d2 (diff) | |
download | bash-completion-a52c4ea382814cb958cfd432d04ce6fc9f09a84f.tar.gz |
__parse_options: Remove trailing [().]* from completions.
-rw-r--r-- | bash_completion | 4 | ||||
-rw-r--r-- | completions/mysql | 3 | ||||
-rw-r--r-- | test/unit/_parse_help.exp | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/bash_completion b/bash_completion index 53f62647..4b7766f5 100644 --- a/bash_completion +++ b/bash_completion @@ -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/=*/=}" } diff --git a/completions/mysql b/completions/mysql index 646b5317..319e2735 100644 --- a/completions/mysql +++ b/completions/mysql @@ -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" ) ) diff --git a/test/unit/_parse_help.exp b/test/unit/_parse_help.exp index ef28d416..c087562f 100644 --- a/test/unit/_parse_help.exp +++ b/test/unit/_parse_help.exp @@ -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 |