[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 96c641630923e8db735316e5a7f4bef8741cadc2

Ville Skyttä ville.skytta at iki.fi
Sun Oct 10 21:40:23 UTC 2010


The following commit has been merged in the master branch:
commit 96c641630923e8db735316e5a7f4bef8741cadc2
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Mon Oct 11 00:39:50 2010 +0300

    Make _parse_help() work with slash separated options.

diff --git a/CHANGES b/CHANGES
index de2695a..e95f526 100644
--- a/CHANGES
+++ b/CHANGES
@@ -14,7 +14,8 @@ bash-completion (2.x)
   * Add *.gif (Alioth: #312512), *.3gpp, *.3gpp2, and *.awb to mplayer
     filename completions.
   * Add "short" tarball extensions to unxz, unlzma etc completions.
-  * Improve /etc/init.d/*, ipmitool, jar, povray, and sqlite3 completions.
+  * Improve /etc/init.d/*, ipmitool, jar, mencoder, mplayer, povray, sqlite3,
+    and general help parsing completions.
   * Fix p4 and povray completions (Alioth: #312625).
   * Add *.xsd, *.xsl, *.rng, and *.wsdl to xmllint filename completions.
   * Recognize rpm query mode based on the --file, --group, --package, and
@@ -24,7 +25,6 @@ bash-completion (2.x)
   * Make _filedir and _filedir_xspec complete uppercase versions of their
     filename extension arguments in addition to exact case matches.
   * IPv6 known hosts completion fixes (Alioth: #312695, RedHat: #630658).
-  * Improve mplayer and mencoder completions.
   * Fixes to completions for filenames containing tabs (RedHat: #629518).
 
   [ Freddy Vulto ]
diff --git a/bash_completion b/bash_completion
index d4244a0..451e426 100644
--- a/bash_completion
+++ b/bash_completion
@@ -676,7 +676,7 @@ _split_longopt()
 # @param $2  command options (default: --help)
 #
 _parse_help() {
-    $1 ${2:---help} 2>&1 | sed -e '/^[[:space:]]*-/!d' -e 's/,/ /g' | \
+    $1 ${2:---help} 2>&1 | sed -e '/^[[:space:]]*-/!d' -e 's|[,/]| |g' | \
         awk '{ print $1; if ($2 ~ /^-/) { print $2 } }' | sed -e 's|=.*||'
 }
 
diff --git a/test/unit/_parse_help.exp b/test/unit/_parse_help.exp
index c9ced6f..4beb28d 100644
--- a/test/unit/_parse_help.exp
+++ b/test/unit/_parse_help.exp
@@ -61,5 +61,13 @@ set cmd {fn() { printf '%s\n' "--long-arg=-value,--opt2=val"; }; _parse_help fn}
 assert_bash_list "--long-arg\n--opt2" $cmd "two options with values"
 sync_after_int
 
+set cmd {fn() { printf '%s\n' "-m,--mirror"; }; _parse_help fn}
+assert_bash_list "-m\n--mirror" $cmd "short + long"
+sync_after_int
+
+set cmd {fn() { printf '%s\n' "-T/--upload-file"; }; _parse_help fn}
+assert_bash_list "-T\n--upload-file" $cmd "short + long, slash separated"
+sync_after_int
+
 
 teardown

-- 
bash-completion



More information about the Bash-completion-commits mailing list