* 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
This commit is contained in:
David Paleino 2009-01-17 00:31:39 +01:00
parent 8998da40f1
commit b0646ff2d2
2 changed files with 21 additions and 10 deletions

View File

@ -303,6 +303,18 @@ _filedir()
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 @@ complete -F _mysqladmin mysqladmin
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

7
debian/changelog vendored
View File

@ -54,6 +54,10 @@ bash-completion (200811xx) UNRELEASED; urgency=low
(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 @@ bash-completion (200811xx) UNRELEASED; urgency=low
* 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@gmail.com> Fri, 16 Jan 2009 23:03:01 +0100
-- David Paleino <d.paleino@gmail.com> Sat, 17 Jan 2009 00:28:42 +0100
bash-completion (20080705) unstable; urgency=low