Improve rpm group completion.

Displayed completions are still wrong but now at least real ones containing
spaces do work and unusual input does not cause grep errors.
http://lists.alioth.debian.org/pipermail/bash-completion-devel/2009-May/001486.html
This commit is contained in:
Ville Skyttä 2009-06-09 00:13:20 +03:00
parent d677dfe33b
commit 2e641b5c6f
2 changed files with 6 additions and 7 deletions

View File

@ -87,6 +87,7 @@ bash-completion (1.x)
* Split FreeBSD pkg_* completion to contrib/pkg_install.
* Split FreeBSD portupgrade and friends completion to contrib/portupgrade.
* Split Slackware pkgtools completion to contrib/pkgtools.
* Improve rpm group completion (displayed completions are still wrong).
[ Todd Zullinger ]
* Make yum complete on filenames after install, deplist, update and upgrade

View File

@ -22,13 +22,11 @@ _rpm_installed_packages()
_rpm_groups()
{
local IFS=$'\t'
# remove trailing backslash, or grep will complain
cur=${cur%"\\"}
COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \
grep "^$cur" ) )
# backslash escape spaces and translate newlines to tabs
COMPREPLY=( $( echo "${COMPREPLY[@]}" | sed 's/ /\\ /g' | tr '\n' '\t' ) )
# TODO: shown completions are wrong but real ones work nevertheless
# http://lists.alioth.debian.org/pipermail/bash-completion-devel/2009-May/001486.html
local IFS=$'\n'
COMPREPLY=( $( compgen -W "$( rpm -qa $nodig $nosig --queryformat \
'%{group}\n' )" -- $cur ) )
}
_rpm_nodigsig()