- /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then
- # using RHL 7.2 or later - this is quicker than querying the DB
+- /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then
+- # using RHL 7.2 or later - this is quicker than querying the DB
+- COMPREPLY=($(compgen -W "$(command sed -ne \
+- 's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \
++ /var/log/rpmpkgs -nt /var/lib/rpm/rpmdb.sqlite ]]; then
++ # simple list generated by 'rpm -qa' command
++ COMPREPLY=($(compgen -W "$(command cat -ne \
+ /var/log/rpmpkgs)" -- "$cur"))
+ elif type rpmqpack &>/dev/null; then
+ # SUSE's rpmqpack is faster than rpm -qa
+ COMPREPLY=($(compgen -W '$(rpmqpack)' -- "$cur"))
+ else
+ COMPREPLY=($(${1:-rpm} -qa --nodigest --nosignature \
+- --queryformat='%{NAME} ' "$cur*" 2>/dev/null))
++ --queryformat='%{NAME}-%{VERSION}-%{RELEASE}\n' 2>/dev/null | while read x ; do [[ "$x" == "$cur"* ]] && echo $x ; done))
+ fi
+ }
+