[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-151-g1709686

Ville Skyttä ville.skytta at iki.fi
Thu Apr 28 18:45:51 UTC 2011


The following commit has been merged in the master branch:
commit 7b60fc655532e85097d5e5fbea3c17c1fee465fc
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Apr 27 21:44:04 2011 +0300

    _parse_help: Re-fix --foo[=bar] handling.

diff --git a/bash_completion b/bash_completion
index feb520b..9a75b9e 100644
--- a/bash_completion
+++ b/bash_completion
@@ -754,11 +754,11 @@ _parse_help()
              gsub("[,/]", " ");
              x = -1;
              for (i = 1; i <= NF; i++) {
-                 if (sub("^(--.[^<[]*)", "&", $i)) { x = i ; break }
+                 if ($i ~ /^--[^-]/) { x = i ; break }
                  if ($i !~ /^-/) { break }
              }
              if (x == -1) { x = 1 }
-             sub("=.*", "", $x);
+             sub("[=<[].*", "", $x);
              print $x
          }'
 }
diff --git a/test/unit/_parse_help.exp b/test/unit/_parse_help.exp
index 2c95032..1c314bd 100644
--- a/test/unit/_parse_help.exp
+++ b/test/unit/_parse_help.exp
@@ -73,5 +73,13 @@ set cmd {fn() { printf '%s\n' "-f, -F, --foo"; }; _parse_help fn}
 assert_bash_list "--foo" $cmd "short + short + long"
 sync_after_int
 
+set cmd {fn() { printf '%s\n' "--foo[=bar]"; }; _parse_help fn}
+assert_bash_list "--foo" $cmd "long with value and eq sign in brackets"
+sync_after_int
+
+set cmd {fn() { printf '%s\n' "--foo=<bar>"; }; _parse_help fn}
+assert_bash_list "--foo" $cmd "long with value in angle brackets"
+sync_after_int
+
 
 teardown

-- 
bash-completion



More information about the Bash-completion-commits mailing list