[Bash-completion-commits] ./current r1259: * Added _parse_help() to try to parse options listed in $command

David Paleino d.paleino at gmail.com
Fri Jan 16 23:31:39 UTC 2009


------------------------------------------------------------
revno: 1259
committer: David Paleino <d.paleino at gmail.com>
branch nick: current
timestamp: Sat 2009-01-17 00:31:39 +0100
message:
  * Added _parse_help() to try to parse options listed in $command 
    --help
  * Fixed gzip completion to use _parse_help(), since the available 
    options vary with distributions
modified:
  bash_completion
  debian/changelog
-------------- next part --------------
=== modified file 'bash_completion'
--- a/bash_completion	2009-01-16 22:05:07 +0000
+++ b/bash_completion	2009-01-16 23:31:39 +0000
@@ -303,6 +303,18 @@
 	COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
 }
 
+# This function tries to parse the output of $command --help
+#
+_parse_help() {
+	local cmd
+	cmd=$1
+	$cmd --help | \
+		grep -- "^[[:space:]]*-" | \
+		tr "," " " | \
+		awk '{print $1; if ($2 ~ /-.*/) { print $2 } }' | \
+		sed -e "s:=.*::g"
+}
+
 # This function completes on signal names
 #
 _signals()
@@ -3357,20 +3369,16 @@
 have gzip &&
 _gzip()
 {
-	local cur prev xspec
+	local cur prev xspec helpopts
 
 	COMPREPLY=()
 	cur=`_get_cword`
 	prev=${COMP_WORDS[COMP_CWORD-1]}
+	helpopts=`_parse_help gzip`
 
 	if [[ "$cur" == -* ]]; then
-		COMPREPLY=( $( compgen -W '-c -d -f \
-			-h -l -L -n -N -q -r -S -t -v -V \
-			-1 -2 -3 -4 -5 -6 -7 -8 -9 \
-			--stdout --decompress --force --help --list \
-			--license --no-name --name --quiet --recursive \
-			--suffix --test --verbose --version --fast \
-			--best --rsyncable' -- $cur ) )
+		COMPREPLY=( $( compgen -W "$helpopts -2 -3 -4 -5 -6 -7 -8" \
+						-- "$cur" ) )
 		return 0
 	fi
 

=== modified file 'debian/changelog'
--- a/debian/changelog	2009-01-16 23:27:22 +0000
+++ b/debian/changelog	2009-01-16 23:31:39 +0000
@@ -54,6 +54,10 @@
     (Closes: #272660)
   * Fix dpkg completion bug: it listed only non-Essential packages
     (Closes: #511790)
+  * Added _parse_help() to try to parse options listed in $command 
+    --help
+  * Fixed gzip completion to use _parse_help(), since the available 
+    options vary with distributions
   * Merge from Gentoo:
     - fix 'find' completion so that it properly completes on -?(i)whilename.
       Patch by Ciaran McCreesh.
@@ -92,9 +96,8 @@
   * Add lzma completion (Per ?yvind Karlsen, Ville Skytt?).
   * Add .mp2 and .vdr to mplayer completion (RHBZ: #444467).
   * Add .mkv, .mp2 and .vdr to *xine completion (RHBZ: #444467).
-  * Add --rsyncable to gzip completion.
   
- -- David Paleino <d.paleino at gmail.com>  Fri, 16 Jan 2009 23:03:01 +0100
+ -- David Paleino <d.paleino at gmail.com>  Sat, 17 Jan 2009 00:28:42 +0100
 
 bash-completion (20080705) unstable; urgency=low
 



More information about the Bash-completion-commits mailing list