public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-bashcomp r98 - trunk
@ 2010-05-04  3:19 Jeremy Olexa (darkside)
  0 siblings, 0 replies; only message in thread
From: Jeremy Olexa (darkside) @ 2010-05-04  3:19 UTC (permalink / raw
  To: gentoo-commits

Author: darkside
Date: 2010-05-04 03:19:07 +0000 (Tue, 04 May 2010)
New Revision: 98

Modified:
   trunk/gentoo
Log:
Fix filtering of categories and packages. Bug 301582, patches by Jacek Sowi?\197?\132ski

Modified: trunk/gentoo
===================================================================
--- trunk/gentoo	2010-05-04 03:15:48 UTC (rev 97)
+++ trunk/gentoo	2010-05-04 03:19:07 UTC (rev 98)
@@ -93,11 +93,14 @@
         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 @@
                         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 \




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-05-04  3:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-04  3:19 [gentoo-commits] gentoo-bashcomp r98 - trunk Jeremy Olexa (darkside)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox