[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-283-g0bc2bb5

Ville Skyttä ville.skytta at iki.fi
Wed May 11 16:42:14 UTC 2011


The following commit has been merged in the master branch:
commit b8b46f9c27380151bd7308ab905cc6dbaf5402cc
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed May 11 19:28:17 2011 +0300

    _parse_help: Pick long options also from "-f FOO, --foo=FOO".

diff --git a/bash_completion b/bash_completion
index 1566f79..03d8942 100644
--- a/bash_completion
+++ b/bash_completion
@@ -788,6 +788,11 @@ _parse_help()
     "$cmd" ${2:---help} 2>&1 | while read -r line; do
 
         [[ $line == *([ $'\t'])-* ]] || continue
+        # transform "-f FOO, --foo=FOO" to "-f , --foo=FOO" etc
+        while [[ $line =~ \
+            ((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+\]? ]]; do
+            line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"}
+        done
         __parse_options "$line"
 
     done
diff --git a/test/unit/_parse_help.exp b/test/unit/_parse_help.exp
index 9c38dea..ef28d41 100644
--- a/test/unit/_parse_help.exp
+++ b/test/unit/_parse_help.exp
@@ -113,5 +113,13 @@ set cmd {fn() { printf '%s\n' "----\n---foo\n----- bar"; }; _parse_help fn}
 assert_bash_list "" $cmd "more than two dashes"
 sync_after_int
 
+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' "-f [FOO], --foo[=FOO]"; }; _parse_help fn}
+assert_bash_list "--foo" $cmd "-f \[FOO\], --foo\[=FOO\]"
+sync_after_int
+
 
 teardown

-- 
bash-completion



More information about the Bash-completion-commits mailing list