From 9753c64f8ab5c9d805566dbbbd7a702a0db87982 Mon Sep 17 00:00:00 2001 From: Jeremy Olexa Date: Tue, 4 May 2010 03:19:07 +0000 Subject: Fix filtering of categories and packages. Bug 301582, patches by Jacek SowiƄski MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/; revision=98 --- gentoo | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/gentoo b/gentoo index fdc7afb..3c78ee6 100644 --- a/gentoo +++ b/gentoo @@ -93,11 +93,14 @@ _pkgname() if [[ $cur == */* ]]; then # Once the category has been completed, it's safe to use ${portdir} # to continue completion. + local ww=$(\ + for pd in ${portdir} ; do + builtin cd ${pd}; + compgen -W "$(compgen -G "${cur}*")" -- "${cur}" ; + done) COMPREPLY=($(\ - for pd in ${portdir} ; do \ - builtin cd ${pd}; \ - compgen -W "$(compgen -G "${cur}*")" -- "${cur}" ; \ - done)) + for x in ${ww}; do echo $x; done|sort -u + )) # When we've completed most of the name, also display the version for # possible completion. if [[ ${#COMPREPLY[@]} -le 1 || ${cur:${#cur}-1:1} == "-" ]] && @@ -112,13 +115,19 @@ _pkgname() done)) fi else - COMPREPLY=( $(compgen -W "$(\ - for pd in ${portdir} ; do \ - if [[ -d ${pd}/metadata/cache ]] ; then - builtin cd ${pd}/metadata/cache; \ - compgen -G "$cur*" -S / ; \ - fi ; \ - done)" -- $cur) ) + # 1. Collect all the categories among ${portdir} + local ww=$(\ + for pd in ${portdir}; do + builtin cd ${pd}; + compgen -X "!@(*-*|virtual)" -S '/' -G "$cur*"; + done) + + # 2. Now ugly hack to delete duplicate categories + local w x + for x in ${ww} ; do w="${x}\n${w}"; done + local words=$(echo -e ${w} | sort -u) + + COMPREPLY=($(compgen -W "$words" -- $cur)) if [[ ${#COMPREPLY[@]} == 1 ]]; then COMPREPLY=($(compgen -W "$(\ for pd in ${portdir} ; do \ -- cgit v1.2.3-65-gdbad