1 |
Author: darkside |
2 |
Date: 2010-05-04 03:19:07 +0000 (Tue, 04 May 2010) |
3 |
New Revision: 98 |
4 |
|
5 |
Modified: |
6 |
trunk/gentoo |
7 |
Log: |
8 |
Fix filtering of categories and packages. Bug 301582, patches by Jacek Sowi?\197?\132ski |
9 |
|
10 |
Modified: trunk/gentoo |
11 |
=================================================================== |
12 |
--- trunk/gentoo 2010-05-04 03:15:48 UTC (rev 97) |
13 |
+++ trunk/gentoo 2010-05-04 03:19:07 UTC (rev 98) |
14 |
@@ -93,11 +93,14 @@ |
15 |
if [[ $cur == */* ]]; then |
16 |
# Once the category has been completed, it's safe to use ${portdir} |
17 |
# to continue completion. |
18 |
+ local ww=$(\ |
19 |
+ for pd in ${portdir} ; do |
20 |
+ builtin cd ${pd}; |
21 |
+ compgen -W "$(compgen -G "${cur}*")" -- "${cur}" ; |
22 |
+ done) |
23 |
COMPREPLY=($(\ |
24 |
- for pd in ${portdir} ; do \ |
25 |
- builtin cd ${pd}; \ |
26 |
- compgen -W "$(compgen -G "${cur}*")" -- "${cur}" ; \ |
27 |
- done)) |
28 |
+ for x in ${ww}; do echo $x; done|sort -u |
29 |
+ )) |
30 |
# When we've completed most of the name, also display the version for |
31 |
# possible completion. |
32 |
if [[ ${#COMPREPLY[@]} -le 1 || ${cur:${#cur}-1:1} == "-" ]] && |
33 |
@@ -112,13 +115,19 @@ |
34 |
done)) |
35 |
fi |
36 |
else |
37 |
- COMPREPLY=( $(compgen -W "$(\ |
38 |
- for pd in ${portdir} ; do \ |
39 |
- if [[ -d ${pd}/metadata/cache ]] ; then |
40 |
- builtin cd ${pd}/metadata/cache; \ |
41 |
- compgen -G "$cur*" -S / ; \ |
42 |
- fi ; \ |
43 |
- done)" -- $cur) ) |
44 |
+ # 1. Collect all the categories among ${portdir} |
45 |
+ local ww=$(\ |
46 |
+ for pd in ${portdir}; do |
47 |
+ builtin cd ${pd}; |
48 |
+ compgen -X "!@(*-*|virtual)" -S '/' -G "$cur*"; |
49 |
+ done) |
50 |
+ |
51 |
+ # 2. Now ugly hack to delete duplicate categories |
52 |
+ local w x |
53 |
+ for x in ${ww} ; do w="${x}\n${w}"; done |
54 |
+ local words=$(echo -e ${w} | sort -u) |
55 |
+ |
56 |
+ COMPREPLY=($(compgen -W "$words" -- $cur)) |
57 |
if [[ ${#COMPREPLY[@]} == 1 ]]; then |
58 |
COMPREPLY=($(compgen -W "$(\ |
59 |
for pd in ${portdir} ; do \ |