summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Olexa <darkside@gentoo.org>2010-05-04 03:19:07 +0000
committerJeremy Olexa <darkside@gentoo.org>2010-05-04 03:19:07 +0000
commit9753c64f8ab5c9d805566dbbbd7a702a0db87982 (patch)
treed0c41a45544beb5cfbb50591bf0c8cdbf7f8d884
parentComplete equery depgraph on all package names, bug 298916 patch by Jacek Sowi... (diff)
downloadgentoo-bashcomp-9753c64f8ab5c9d805566dbbbd7a702a0db87982.tar.gz
gentoo-bashcomp-9753c64f8ab5c9d805566dbbbd7a702a0db87982.tar.bz2
gentoo-bashcomp-9753c64f8ab5c9d805566dbbbd7a702a0db87982.zip
Fix filtering of categories and packages. Bug 301582, patches by Jacek SowiƄski
svn path=/trunk/; revision=98
-rw-r--r--gentoo31
1 files 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 \