Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
Date: Sun, 31 Aug 2014 21:19:11
Message-Id: 1409512737.1781d5b81021858db447d4c63f68e081e320fd00.mgorny@gentoo
1 commit: 1781d5b81021858db447d4c63f68e081e320fd00
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Aug 31 19:18:57 2014 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Aug 31 19:18:57 2014 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-bashcomp.git;a=commit;h=1781d5b8
7
8 Split completions by completed command.
9
10 ---
11 completions/browser-config | 31 +
12 completions/distcc-config | 41 ++
13 completions/ebuild | 34 +
14 completions/ekeyword | 46 ++
15 completions/emerge | 410 +++++++++++
16 completions/epkginfo | 28 +
17 completions/epm | 48 ++
18 completions/equery | 280 ++++++++
19 completions/euse | 60 ++
20 completions/gcc-config | 45 ++
21 completions/gentoo | 1652 --------------------------------------------
22 completions/glsa-check | 33 +
23 completions/java-config | 158 +++++
24 completions/metagen | 30 +
25 completions/portageq | 87 +++
26 completions/rc | 21 +
27 completions/rc-service | 111 +++
28 completions/rc-status | 28 +
29 completions/rc-update | 40 ++
30 completions/revdep-rebuild | 55 ++
31 completions/splat | 33 +
32 completions/webapp-config | 169 +++++
33 22 files changed, 1788 insertions(+), 1652 deletions(-)
34
35 diff --git a/completions/browser-config b/completions/browser-config
36 new file mode 100644
37 index 0000000..158ca42
38 --- /dev/null
39 +++ b/completions/browser-config
40 @@ -0,0 +1,31 @@
41 +# Gentoo Linux Bash Shell Command Completion
42 +#
43 +# Copyright 1999-2013 Gentoo Foundation
44 +# Distributed under the terms of the GNU General Public License, v2 or later
45 +
46 +#
47 +# browser-config completion command
48 +#
49 +_browserconfig()
50 +{
51 + local cur prev
52 + COMPREPLY=()
53 + cur="${COMP_WORDS[COMP_CWORD]}"
54 + prev="${COMP_WORDS[COMP_CWORD-1]}"
55 + if [[ ${COMP_CWORD} -eq 1 ]]; then
56 + COMPREPLY=($(compgen -W '-b -h -m' -- ${cur}))
57 + elif [[ "${prev}" == "-b" ]]; then
58 + COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/usr/share/browser-config/*; do [ -f $i ] && echo ${i##*/}; done)" $cur))
59 + elif [[ "${prev}" == "-m" ]]; then
60 + COMPREPLY=($(compgen -W "same_window new_window new_tab new_browser" -- ${cur}))
61 + if [[ -z "${COMPREPLY}" ]]; then
62 + COMPREPLY=''
63 + fi
64 + else
65 + unset COMPREPLY
66 + fi
67 + return 0
68 +} &&
69 +complete -F _browserconfig browser-config
70 +
71 +# vim: ft=sh:et:ts=4:sw=4:tw=80
72
73 diff --git a/completions/distcc-config b/completions/distcc-config
74 new file mode 100644
75 index 0000000..41c315f
76 --- /dev/null
77 +++ b/completions/distcc-config
78 @@ -0,0 +1,41 @@
79 +# Gentoo Linux Bash Shell Command Completion
80 +#
81 +# Copyright 1999-2013 Gentoo Foundation
82 +# Distributed under the terms of the GNU General Public License, v2 or later
83 +
84 +#
85 +# distcc-config completion command
86 +#
87 +_distccconfig()
88 +{
89 + local cur curword numwords opts
90 + COMPREPLY=()
91 + cur="${COMP_WORDS[COMP_CWORD]}"
92 + numwords=${#COMP_WORDS[*]}
93 + curword=${COMP_CWORD}
94 + if [[ ${numwords} -gt 3 ]]; then
95 + unset COMPREPLY
96 + return 0
97 + fi
98 + if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
99 + if [[ ${numwords} -le 2 ]] && [[ ${curword} -eq 1 ]]; then
100 + opts="--get-hosts \
101 + --get-verbose \
102 + --get-log \
103 + --set-hosts \
104 + --set-verbose \
105 + --set-log \
106 + --add-path \
107 + --no-path"
108 + else
109 + opts=""
110 + fi
111 + else
112 + opts=""
113 + fi
114 + COMPREPLY=($(compgen -W "${opts}" | grep ^$cur))
115 + return 0
116 +} &&
117 +complete -F _distccconfig distcc-config
118 +
119 +# vim: ft=sh:et:ts=4:sw=4:tw=80
120
121 diff --git a/completions/ebuild b/completions/ebuild
122 new file mode 100644
123 index 0000000..cd6e17e
124 --- /dev/null
125 +++ b/completions/ebuild
126 @@ -0,0 +1,34 @@
127 +# Gentoo Linux Bash Shell Command Completion
128 +#
129 +# Copyright 1999-2013 Gentoo Foundation
130 +# Distributed under the terms of the GNU General Public License, v2 or later
131 +
132 +#
133 +# ebuild completion command
134 +#
135 +_ebuild()
136 +{
137 + local cur opts
138 + COMPREPLY=()
139 + cur="${COMP_WORDS[COMP_CWORD]}"
140 +
141 + opts="help setup clean fetch digest manifest unpack compile test preinst \
142 + install postinst qmerge merge unmerge prerm postrm config package rpm \
143 + configure prepare"
144 +
145 + if [[ $COMP_CWORD -eq 1 ]] ; then
146 + COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) \
147 + $(compgen -d -- ${cur}) \
148 + $(compgen -W '--debug --force --help --ignore-default-opts --skip-manifest' -- ${cur}))
149 +
150 + elif [[ $COMP_CWORD -eq 2 && "${COMP_WORDS[1]}" = "--debug --force --ignore-default-opts --skip-manifest" ]] ; then
151 + COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) $(compgen -d -- ${cur}))
152 +
153 + elif [[ $COMP_CWORD -ge 2 ]] ; then
154 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
155 + fi
156 + return 0
157 +} &&
158 +complete -o filenames -F _ebuild ebuild
159 +
160 +# vim: ft=sh:et:ts=4:sw=4:tw=80
161
162 diff --git a/completions/ekeyword b/completions/ekeyword
163 new file mode 100644
164 index 0000000..3bf3006
165 --- /dev/null
166 +++ b/completions/ekeyword
167 @@ -0,0 +1,46 @@
168 +# Gentoo Linux Bash Shell Command Completion
169 +#
170 +# Copyright 1999-2013 Gentoo Foundation
171 +# Distributed under the terms of the GNU General Public License, v2 or later
172 +
173 +source "@helpersdir@/gentoo-common.sh"
174 +
175 +#
176 +# ekeyword completion
177 +#
178 +
179 +_ekeyword()
180 +{
181 + local cur portdir archl_s archl_u archl_r archl_m arch
182 + COMPREPLY=()
183 + cur="${COMP_WORDS[COMP_CWORD]}"
184 + portdir=$(_portdir)
185 +
186 + [[ -f ${portdir}/profiles/arch.list ]] || return 0
187 +
188 + for arch in all $(< ${portdir}/profiles/arch.list) ; do
189 + archl_m="${archl_m} -${arch}"
190 + archl_u="${archl_u} ~${arch}"
191 + archl_r="${archl_r} ^${arch}"
192 + archl_s="${archl_s} ${arch}"
193 + done
194 +
195 + case ${cur} in
196 + -*)
197 + COMPREPLY=($(compgen -W "${archl_m}" -- ${cur}))
198 + ;;
199 + ~*)
200 + COMPREPLY=($(compgen -W "${archl_u}" -- ${cur}))
201 + ;;
202 + ^*)
203 + COMPREPLY=($(compgen -W "${archl_r}" -- ${cur}))
204 + ;;
205 + *)
206 + COMPREPLY=($(compgen -W "${archl_s}" -- ${cur}))
207 + _filedir 'ebuild'
208 + ;;
209 + esac
210 +} &&
211 +complete -o filenames -F _ekeyword ekeyword
212 +
213 +# vim: ft=sh:et:ts=4:sw=4:tw=80
214
215 diff --git a/completions/emerge b/completions/emerge
216 new file mode 100644
217 index 0000000..63c02b4
218 --- /dev/null
219 +++ b/completions/emerge
220 @@ -0,0 +1,410 @@
221 +# Gentoo Linux Bash Shell Command Completion
222 +#
223 +# Copyright 1999-2013 Gentoo Foundation
224 +# Distributed under the terms of the GNU General Public License, v2 or later
225 +
226 +source "@helpersdir@/gentoo-common.sh"
227 +
228 +#
229 +# emerge completion command
230 +#
231 +_emerge()
232 +{
233 + local c cur prev curword numwords opts cond prepend
234 + local words stophere i x
235 + local action actionpos sysactions pkgpos
236 + local portdir=$(_portdir -o)
237 + COMPREPLY=()
238 + cur="${COMP_WORDS[COMP_CWORD]}"
239 + prev="${COMP_WORDS[COMP_CWORD-1]}"
240 + numwords=${#COMP_WORDS[*]}
241 + curword=${COMP_CWORD}
242 + opts=''
243 +
244 + if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
245 + COMPREPLY=($(compgen -f -- ${cur}))
246 + return 0
247 + fi
248 +
249 + # find action
250 + for x in ${COMP_LINE} ; do
251 + if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \
252 + [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|regen|resume|search|sync|unmerge) ]]
253 + then
254 + action=${x}
255 + break
256 + fi
257 + done
258 +
259 + if [[ -n ${action} ]]; then
260 + for ((i = 0; i < ${numwords}; i++ )); do
261 + if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
262 + actionpos=${i}
263 + pkgpos=$((actionpos + 1))
264 + break
265 + fi
266 + done
267 +
268 + if [[ ${action} == -* && ${action} != --* ]] ; then
269 + case "${action}" in
270 + -*C*) action='--unmerge' ;;
271 + -*P*) action='--prune' ;;
272 + -*c*) action='--clean' ;;
273 + -*s*) action='--search' ;;
274 + esac
275 + fi
276 + else
277 + for ((i = 1; i < ${numwords}; i++ )); do
278 + if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
279 + pkgpos=${i}
280 + break
281 + fi
282 + done
283 + [[ -z ${pkgpos} ]] && pkgpos=${numwords}
284 + fi
285 +
286 + # Handle special cases.
287 + if [[ ${action} == "--search" ]] || [[ ${COMP_LINE} == *" "-@(S|-searchdesc)* ]] || \
288 + [[ ${COMP_LINE} == *" "-@(V|-version)* ]] || [[ ${action} == "--metadata" ]]
289 + then
290 + unset COMPREPLY
291 + return 0
292 + elif [[ ${COMP_LINE} == *" "-@(h|-help)* ]] ; then
293 + unset COMPREPLY
294 + [[ ${curword} -eq 2 ]] && COMPREPLY=($(compgen -W 'system world --sync' -- ${cur}))
295 + return 0
296 + fi
297 +
298 + # Complete on options.
299 + if [[ ${cur} == -* ]]; then
300 + # If a resume option was specified, it needs special handling.
301 + if [[ ${COMP_LINE} =~ --(resume|skipfirst) ]] ; then
302 + if [[ ${cur} == --* ]]; then
303 + opts="--ask --pretend --resume --skipfirst"
304 + elif [[ ${cur} == -* ]]; then
305 + [[ ${COMP_LINE} =~ --(ask|pretend) ]] && opts="-a -p"
306 + fi
307 + elif [[ ${cur} == --* ]]; then
308 + # Complete on long options.
309 + opts="--alphabetical --ask \
310 + --buildpkg --buildpkgonly \
311 + --changelog --clean --color=y --color=n --columns --complete-graph --config \
312 + --debug --deep --depclean \
313 + --emptytree \
314 + --fetch-all-uri --fetchonly \
315 + --getbinpkg --getbinpkgonly \
316 + --ignore-default-opts --info \
317 + --jobs= \
318 + --keep-going \
319 + --metadata \
320 + --newuse --noconfmem --nodeps --noreplace --nospinner \
321 + --oneshot --onlydeps \
322 + --pretend --prune \
323 + --quiet \
324 + --reinstall=changed-use --regen \
325 + --search \
326 + --sync \
327 + --tree \
328 + --unmerge --update --upgradeonly --usepkg --usepkgonly \
329 + --verbose \
330 + --with-bdeps=y --with-bdeps=n"
331 + if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
332 + opts="${opts} --help --resume --searchdesc --version"
333 + fi
334 + elif [[ ${cur} == -* ]]; then
335 + # Complete on short options.
336 + opts="-B -D -G -K -N -O -a -b -d -e -f -g -k -l -n -o -p -q -t -u -v"
337 + if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
338 + opts="${opts} -h -S -V"
339 + fi
340 + if [[ -z ${action} ]] && [[ ${curword} -eq $((pkgpos - 1)) ]] ; then
341 + opts="${opts} -C -P -c -s"
342 + fi
343 + fi
344 +
345 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
346 +
347 + # NOTE: This slows things down!
348 + # (Adapted from bash_completion by Ian Macdonald <ian@×××××××.org>)
349 + # This removes any options from the list of completions that have
350 + # already been specified on the command line.
351 + COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
352 + (while read -d ' ' i; do
353 + [[ -z ${i} ]] && continue
354 + # flatten array with spaces on either side,
355 + # otherwise we cannot grep on word boundaries of
356 + # first and last word
357 + COMPREPLY=" ${COMPREPLY[@]} "
358 + # remove word from list of completions
359 + COMPREPLY=(${COMPREPLY/ ${i%% *} / })
360 + done
361 + echo ${COMPREPLY[@]})))
362 +
363 + return 0
364 + fi # options
365 +
366 + # Stop completion if a special case is encountered.
367 + if [[ ${action} =~ (system|world) ]] || \
368 + [[ ${COMP_LINE} =~ --(depclean|metadata|regen|resume|skipfirst|sync) ]]
369 + then
370 + unset COMPREPLY
371 + return 0
372 + fi
373 +
374 + # Complete on installed packages when unmerging.
375 + if [[ "${action}" == '--unmerge' ]]; then
376 + if [[ -n "${cur}" ]] ; then
377 + if [[ "${cur}" == */* ]]; then
378 + words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")
379 + else
380 + words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -S '/' -G "${cur}*")
381 +
382 + local n=0
383 + for i in ${words} ; do
384 + [[ ${i} == ${cur}* ]] && n=$((n+1))
385 + done
386 +
387 + if [[ ${n} -eq 1 ]] ; then
388 + words="$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -G "*-*/*")"
389 + fi
390 + fi
391 + COMPREPLY=($(for i in ${words} ; do \
392 + [[ ${i} == ${cur}* ]] && echo ${i} ; \
393 + done))
394 + else
395 + COMPREPLY=($(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -S '/' -G "*-*"))
396 + fi
397 +
398 + [[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg
399 + return 0
400 + fi
401 +
402 + # Check for conditional.
403 + cond="${cur%%[A-Za-z0-9]*}"
404 + cur="${cur:${#cond}}"
405 + if [[ ${cond:0:1} == "'" || ${cond:0:1} == '"' ]] ; then
406 + prepend="-P ${cond:1}"
407 + c="${cond:1}"
408 + else
409 + c="${cond}"
410 + fi
411 +
412 + # Handle cases where a conditional is specified.
413 + if [[ -n "${cond}" ]]; then
414 + if [[ -n "${cur}" ]]; then
415 + if [[ ${cur} == */* ]]; then
416 + if [[ ${cur} == *-[0-9]* ]] ; then
417 + words="$(\
418 + for pd in ${portdir} ; do \
419 + builtin cd ${pd} ; \
420 + local cat="${cur%/*}" ; \
421 + local pkg="$(echo ${cur%-[0-9]*})" ; \
422 + pkg="${pkg##*/}" ; \
423 + for x in ${cat}/${pkg}/*.ebuild ; do \
424 + [[ -f ${x} ]] || continue ; \
425 + x="${x/${pkg}\/}" ; \
426 + echo "${x%*.ebuild}" ; \
427 + done ; \
428 + done)"
429 + else
430 + words="$(\
431 + for pd in ${portdir} ; do \
432 + builtin cd ${pd}; \
433 + compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \
434 + done)"
435 + fi
436 +
437 + local w
438 + for x in $words ; do
439 + w="${x}\n${w}"
440 + done
441 +
442 + words=$(echo -ne ${w} | sort | uniq)
443 + COMPREPLY=( ${words} )
444 +
445 + # Complete on the specific versions (if appropriate).
446 + # TODO - see if we can use _pkgname
447 + if [[ ${#COMPREPLY[@]} -le 1 ]]; then
448 + COMPREPLY=($(
449 + for pd in ${portdir}; do
450 + if [[ -d ${pd}/metadata/md5-cache ]]; then
451 + builtin cd ${pd}/metadata/md5-cache
452 + compgen ${prepend} -G "${cur}*" -- "${cur}"
453 + elif [[ -d ${pd}/metadata/cache ]]; then
454 + builtin cd ${pd}/metadata/cache
455 + compgen ${prepend} -G "${cur}*" -- "${cur}"
456 + else
457 + builtin cd ${pd}
458 + local cat="${cur%/*}"
459 + local pkg="$(echo ${cur%-[0-9]*}*)"
460 + pkg="${pkg##*/}"
461 + for x in ${cat}/${pkg}/*.ebuild; do
462 + [[ -f "${x}" ]] || continue
463 + x="${x/${pkg}\/}"
464 + if [[ ${cond:0:1} == "'" ]] || [[ ${cond:0:1} == '"' ]]; then
465 + echo "${c}${x%*.ebuild}"
466 + else
467 + echo "${x%*.ebuild}"
468 + fi
469 + done
470 + fi
471 + done
472 + ))
473 + else
474 + COMPREPLY=($(compgen ${prepend} -W "${words}" -- $cur))
475 + fi
476 + else
477 + words="$(\
478 + for pd in ${portdir} ; do \
479 + builtin cd ${pd} ; \
480 + compgen ${prepend} -S '/' -G "${cur}*" -- "${cur}" ; \
481 + done)"
482 +
483 + local w
484 + for x in words ; do
485 + w="${x}\n${w}"
486 + done
487 +
488 + COMPREPLY=($(echo -e ${w} | uniq))
489 + [[ ${#COMPREPLY[@]} = 1 ]] && \
490 + COMPREPLY=($(\
491 + for pd in ${portdir} ; do \
492 + builtin cd ${pd} ; \
493 + compgen ${prepend} -G "${cur}*/*" -- "${cur}" ; \
494 + done))
495 + fi
496 + else
497 + words="$(\
498 + for pd in ${portdir} ; do \
499 + builtin cd ${pd}; \
500 + compgen -G "*-*"; \
501 + done)"
502 + COMPREPLY=($(compgen -W "${words}" -- "${cur}"))
503 + fi
504 +
505 + # If all else fails, try to complete on package names without the
506 + # category being specified.
507 + if [[ -z "${COMPREPLY}" ]]; then
508 + words="$(\
509 + for pd in ${portdir} ; do \
510 + builtin cd ${pd}; \
511 + for i in *-*/${cur}*; do \
512 + [[ -d $i ]] && echo ${i##*/}; \
513 + done ; \
514 + done)"
515 +
516 + COMPREPLY=($(compgen ${prepend} -W "${words}" -- ${cur}))
517 +
518 + if [[ ${#COMPREPLY[@]} -le 1 ]]; then
519 + # Now complete on the specific versions.
520 + words="$(
521 + for pd in ${portdir}; do
522 + if [[ -d ${pd}/metadata/md5-cache ]]; then
523 + builtin cd ${pd}/metadata/md5-cache
524 + for i in */${cur}*; do
525 + [[ -f $i ]] && echo ${i##*/}
526 + done
527 + elif [[ -d ${pd}/metadata/cache ]]; then
528 + builtin cd ${pd}/metadata/cache
529 + for i in */${cur}*; do
530 + [[ -f $i ]] && echo ${i##*/}
531 + done
532 + fi
533 + done
534 + )"
535 + COMPREPLY=($(compgen ${prepend} -W "${words}" -- "${cur}"))
536 + fi
537 + fi
538 + return 0
539 + fi
540 +
541 + # Complete on packages.
542 + #
543 + # Only allow these actions if no packages have been specified.
544 + #
545 + # TODO: This doesn't block these actions if no categories are
546 + # specified. Please fix me.
547 + #
548 + # e.g. emerge -a gentoo-dev-sources
549 + #
550 + # will still allow system and world actions to be specified,
551 + # as opposed to
552 + #
553 + # emerge -a sys-kernel/gentoo-dev-sources
554 + #
555 + if [[ ${COMP_CWORD} -eq 1 ]] || [[ ! " ${COMP_LINE} " == *" "*[/]*" "* ]] ; then
556 + sysactions=$'\n'"system"$'\n'"world"
557 + else
558 + sysactions=''
559 + fi
560 +
561 + if [[ -n "${cur}" ]] ; then
562 + if [[ ${cur} == */* ]] ; then
563 + words=$(\
564 + for pd in ${portdir} ; do \
565 + builtin cd ${pd}; \
566 + compgen -X "*metadata.xml" -G "${cur}*" ; \
567 + done)"${sysactions}"
568 + else
569 + local ww=$(\
570 + for pd in ${portdir} ; do \
571 + builtin cd ${pd} ; \
572 + compgen -X "!@(*-*|virtual)" -S '/' -G "${cur}*"; \
573 + done)"${sysactions}"
574 + # complete on virtuals
575 + ww="${ww} $(\
576 + for pd in ${portdir} ; do \
577 + if [[ -d ${pd}/profiles ]] ; then
578 + find ${pd}/profiles -name virtuals -exec \
579 + sed -n -e 's|^\(virtual/[[:alnum:]]\+\).*$|\1|p' {} \; | \
580 + sort -u
581 + fi ; \
582 + done)"
583 +
584 + local w
585 + for x in ${ww} ; do w="${x}\n${w}" ; done
586 +
587 + words=$(echo -e ${w} | sort -u)
588 +
589 + local n=0
590 + for i in ${words} ; do
591 + [[ ${i} == ${cur}* ]] && n=$((n+1))
592 + done
593 +
594 + if [[ ${n} -eq 1 ]] ; then
595 + words=$(for pd in ${portdir} ; do \
596 + builtin cd ${pd} ; \
597 + compgen -G "*-*/*" ; \
598 + done)"${sysactions}"
599 + fi
600 + fi
601 + COMPREPLY=($(for i in ${words} ; do \
602 + [[ ${i} == ${cur}* ]] && echo ${i} ; \
603 + done))
604 + else
605 + words="$(\
606 + for pd in ${portdir} ; do \
607 + builtin cd ${pd} ; \
608 + compgen -S '/' -G "*-*" ; \
609 + done)""${sysactions}"
610 + COMPREPLY=($(compgen -W "${words}" -- ${cur}))
611 + fi
612 +
613 + # If all else fails, try to complete on package names without the
614 + # category being specified.
615 + if [[ -z "${COMPREPLY}" ]]; then
616 + words="$(\
617 + for pd in ${portdir} ; do \
618 + builtin cd ${pd}; \
619 + for i in [a-z]*-[a-z0-9]*/${cur}*; do \
620 + [[ -d $i ]] && echo ${i##*/}; \
621 + done ; \
622 + done)"
623 + COMPREPLY=($(compgen -W "${words}" -- ${cur}))
624 + fi
625 +
626 + return 0
627 +} &&
628 +complete -o filenames -F _emerge emerge
629 +
630 +# vim: ft=sh:et:ts=4:sw=4:tw=80
631
632 diff --git a/completions/epkginfo b/completions/epkginfo
633 new file mode 100644
634 index 0000000..34c81f3
635 --- /dev/null
636 +++ b/completions/epkginfo
637 @@ -0,0 +1,28 @@
638 +# Gentoo Linux Bash Shell Command Completion
639 +#
640 +# Copyright 1999-2013 Gentoo Foundation
641 +# Distributed under the terms of the GNU General Public License, v2 or later
642 +
643 +source "@helpersdir@/gentoo-common.sh"
644 +
645 +#
646 +# epkginfo completion
647 +#
648 +
649 +_epkginfo()
650 +{
651 + local cur prev
652 + cur="${COMP_WORDS[COMP_CWORD]}"
653 + prev="${COMP_WORDS[COMP_CWORD-1]}"
654 +
655 + # Only complete if the previous entry on the command line is not
656 + # a package name.
657 + if [[ ${COMP_CWORD} -eq 1 || ${prev:0:1} == "-" ]]; then
658 + _equery_meta $cur
659 + fi
660 +
661 + return 0
662 +} &&
663 +complete -F _epkginfo epkginfo
664 +
665 +# vim: ft=sh:et:ts=4:sw=4:tw=80
666
667 diff --git a/completions/epm b/completions/epm
668 new file mode 100644
669 index 0000000..e8a8caa
670 --- /dev/null
671 +++ b/completions/epm
672 @@ -0,0 +1,48 @@
673 +# Gentoo Linux Bash Shell Command Completion
674 +#
675 +# Copyright 1999-2013 Gentoo Foundation
676 +# Distributed under the terms of the GNU General Public License, v2 or later
677 +
678 +source "@helpersdir@/gentoo-common.sh"
679 +
680 +_epm() {
681 + local cur prev opts
682 + COMPREPLY=()
683 + cur="${COMP_WORDS[COMP_CWORD]}"
684 + prev="${COMP_WORDS[COMP_CWORD]}"
685 + opts="-q --query -V -y --verify -e --erase --help"
686 +
687 + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
688 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
689 + return 0
690 + fi
691 +
692 + case "${prev}" in
693 + --help)
694 + COMPREPLY=()
695 + ;;
696 + -q|--query)
697 + _pkgname -I ${cur}
698 + COMPREPLY=($(compgen -W "${COMPREPLY[@]} -l -f -G -a" -- ${cur}))
699 + ;;
700 + *)
701 + local x all=0 file=0
702 + for x in ${COMP_WORDS[@]} ; do
703 + [[ ${x} == -* ]] || continue
704 + [[ ${x} == *f* ]] && file=1
705 + [[ ${x} == *a* ]] && all=1
706 + done
707 +
708 + if [[ ${file} -eq 1 ]] ; then
709 + COMPREPLY=($(compgen -f -- ${cur}))
710 + elif [[ ${all} -eq 1 ]] ; then
711 + COMPREPLY=()
712 + else
713 + _pkgname -I ${cur}
714 + fi
715 + ;;
716 + esac
717 +} &&
718 +complete -o filenames -F _epm epm
719 +
720 +# vim: ft=sh:et:ts=4:sw=4:tw=80
721
722 diff --git a/completions/equery b/completions/equery
723 new file mode 100644
724 index 0000000..a8aa829
725 --- /dev/null
726 +++ b/completions/equery
727 @@ -0,0 +1,280 @@
728 +# Gentoo Linux Bash Shell Command Completion
729 +#
730 +# Copyright 1999-2013 Gentoo Foundation
731 +# Distributed under the terms of the GNU General Public License, v2 or later
732 +
733 +source "@helpersdir@/gentoo-common.sh"
734 +
735 +#
736 +# Bash completion for the Gentoo 'equery' command
737 +#
738 +_equery()
739 +{
740 + local cur prev mode portdir i j
741 + portdir=$(_portdir)
742 + mode="GLOBAL"
743 + COMPREPLY=()
744 + cur="${COMP_WORDS[COMP_CWORD]}"
745 + prev="${COMP_WORDS[COMP_CWORD-1]}"
746 + # Find out what we're currently doing here.
747 + j=0
748 + for i in "${COMP_WORDS[@]}"; do
749 + if [[ $j -lt $COMP_CWORD ]]; then
750 + j=$((j + 1))
751 + case $i in
752 + @(belongs|ch@(anges|eck)|dep@(ends|graph)|files|has?(use)|keywords|list|meta|size|uses|which|b|c|k|d|g|f|a|h|y|l|m|s|u|w))
753 + mode=$i
754 + ;;
755 + esac
756 + fi
757 + done
758 + # Now get to work.
759 + case $mode in
760 + GLOBAL)
761 + # Complete commands and global options.
762 + case $cur in
763 + -*)
764 + COMPREPLY=($(compgen -W "-q --quiet -C --nocolor -h --help -V --version" -- $cur))
765 + ;;
766 + *)
767 + COMPREPLY=($(compgen -W "belongs changes check depends depgraph files has hasuse keywords list meta size uses which" -- $cur))
768 + ;;
769 + esac
770 + ;;
771 + c?(hanges))
772 + # Complete package name only if it is not yet supplied.
773 + if [[ ${prev} == ${mode} ]]; then
774 + case $cur in
775 + -*)
776 + COMPREPLY=($(compgen -W "-h --help" -- $cur))
777 + ;;
778 + *)
779 + _pkgname -A $cur
780 + ;;
781 + esac
782 + else
783 + case $cur in
784 + *)
785 + COMPREPLY=($(compgen -W "-h --help -l --latest -f --full --limit --from --to" -- $cur))
786 + ;;
787 + esac
788 + fi
789 + ;;
790 + f?(iles))
791 + # Only complete if the previous entry on the command line is not
792 + # a package name.
793 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
794 + # --filter=<list>: completion of the files types list
795 + if [[ ${prev} == "-f" || "${cur}" == "--filter="* ]] ; then
796 + COMPREPLY=($(_list_compgen "${cur#--filter=}" , \
797 + dir,obj,sym,dev,fifo,path,conf,cmd,doc,man,info))
798 + return 0
799 + fi
800 + case $cur in
801 + --f*)
802 + # don't handle --filter= with others to avoid space after the "="
803 + COMPREPLY=($(compgen -P "--filter=" \
804 + -W "dir obj sym dev fifo path conf cmd doc man info"))
805 + ;;
806 + -*)
807 + COMPREPLY=($(compgen -W "-h --help -m --md5sum -s --timestamp -t
808 + --type --tree -f --filter=" -- $cur))
809 + ;;
810 + *)
811 + # Only installed packages can have their files listed.
812 + _pkgname -I $cur
813 + ;;
814 + esac
815 + fi
816 + ;;
817 + a|has)
818 + COMPREPLY=($(compgen -W "-h --help -I --exclude-installed -o \
819 + --overlay-tree -p --portage-tree -F --format" -- $cur))
820 + ;;
821 + y|keywords)
822 + # Only complete if the previous entry on the command line is not
823 + # a package name.
824 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
825 + case "${cur}" in
826 + -*)
827 + COMPREPLY=($(compgen -W "-h --help -v --version -a --arch -A
828 + --align -T --top-position -B --bold -C --color -O --overlays
829 + -P --prefix -S --ignore-slot" -- $cur))
830 + ;;
831 + *)
832 + _pkgname -A $cur
833 + ;;
834 + esac
835 + fi
836 + ;;
837 + l?(ist))
838 + # Only complete if the previous entry on the command line is not
839 + # a package name.
840 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
841 + case "${cur}" in
842 + -*)
843 + COMPREPLY=($(compgen -W "-h --help -d --duplicates -b
844 + --binpkgs-missing -f --full-regex -m --mask-reason -I
845 + --exclude-installed -o --overlay-tree -p --portage-tree -F
846 + --format" -- $cur))
847 + ;;
848 + *)
849 + if [[ ${COMP_WORDS[@]} =~ -(p|o) || ${COMP_WORDS[@]} =~ --(portage|overlay)-tree ]]; then
850 + _pkgname -A $cur
851 + else
852 + _pkgname -I $cur
853 + fi
854 + ;;
855 + esac
856 + fi
857 + ;;
858 + b?(elongs))
859 + # Only complete if the previous entry on the command line is not
860 + # a file name.
861 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
862 + case $cur in
863 + -*)
864 + COMPREPLY=($(compgen -W "-h --help -f --full-regex -e
865 + --early-out -n --name-only" -- $cur))
866 + ;;
867 + *)
868 + COMPREPLY=($(compgen -f -- $cur) \
869 + $(compgen -d -S '/' -- $cur))
870 + ;;
871 + esac
872 + fi
873 + ;;
874 + u?(ses))
875 + # Only complete if the previous entry on the command line is not
876 + # a package name.
877 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
878 + case $cur in
879 + -*)
880 + COMPREPLY=($(compgen -W "-h --help -a --all" -- $cur))
881 + ;;
882 + *)
883 + # Complete on all package names.
884 + _pkgname -A $cur
885 + ;;
886 + esac
887 + fi
888 + ;;
889 + w?(hich))
890 + # Only complete if the previous entry on the command line is not
891 + # a package name.
892 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
893 + case $cur in
894 + -*)
895 + COMPREPLY=($(compgen -W "-h --help -m --include-masked" -- $cur))
896 + ;;
897 + *)
898 + # Complete on all package names.
899 + _pkgname -A $cur
900 + ;;
901 + esac
902 + fi
903 + ;;
904 + g|depgraph)
905 + # Only complete if the previous entry on the command line is not
906 + # a package name.
907 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
908 + case $cur in
909 + -*)
910 + COMPREPLY=($(compgen -W "-h --help -A --no-atom -M --no-mask -U
911 + --no-useflags -l --linear --depth" -- $cur))
912 + ;;
913 + *)
914 + # Complete on all package names.
915 + _pkgname -A $cur
916 + ;;
917 + esac
918 + fi
919 + ;;
920 + d?(epends))
921 + # Only complete if the previous entry on the command line is not
922 + # a package name.
923 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
924 + case $cur in
925 + -*)
926 + COMPREPLY=($(compgen -W "-h --help -a --all-packages -D
927 + --indirect --depth" -- $cur))
928 + ;;
929 + *)
930 + case $prev in
931 + -a|--all-packages)
932 + # Complete on all package names.
933 + _pkgname -A $cur
934 + ;;
935 + *)
936 + # Complete on installed package names.
937 + _pkgname -I $cur
938 + ;;
939 + esac
940 + ;;
941 + esac
942 + fi
943 + ;;
944 + m?(eta))
945 + # Only complete if the previous entry on the command line is not
946 + # a package name.
947 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
948 + _equery_meta $cur
949 + fi
950 + ;;
951 + k|check)
952 + # Only complete if the previous entry on the command line is not
953 + # a package name.
954 + if [[ ${prev} == ${mode} ]]; then
955 + case $cur in
956 + -*)
957 + COMPREPLY=($(compgen -W "${COMPREPLY[@]} -h --help -f
958 + --full-regex -o --only-failures" -- ${cur}))
959 + ;;
960 + *)
961 + # Only installed packages can have their integrity verified.
962 + _pkgname -I $cur
963 + ;;
964 + esac
965 + fi
966 + ;;
967 + s?(ize))
968 + # Only complete if the previous entry on the command line is not
969 + # a package name.
970 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
971 + case $cur in
972 + -*)
973 + COMPREPLY=($(compgen -W "-h --help -b --bytes -f
974 + --full-regex" -- $cur))
975 + ;;
976 + *)
977 + # Only installed packages can have their size calculated.
978 + _pkgname -I $cur
979 + ;;
980 + esac
981 + fi
982 + ;;
983 + h?(asuse))
984 + # Only complete if the previous entry on the command line is not
985 + # a package name.
986 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
987 + case $cur in
988 + -*)
989 + COMPREPLY=($(compgen -W "--help -i --installed -I --exclude-installed -p --portage-tree -o --overlay" -- $cur))
990 + ;;
991 + *)
992 + local glob loc
993 + [[ -f ${portdir}/profiles/use.desc ]] || return 0
994 + [[ -f ${portdir}/profiles/use.local.desc ]] || return 0
995 + glob=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
996 + loc=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
997 + COMPREPLY=($(compgen -W "$glob $loc" -- $cur))
998 + ;;
999 + esac
1000 + fi
1001 + ;;
1002 + esac
1003 + return 0
1004 +} &&
1005 +complete -F _equery equery
1006 +
1007 +# vim: ft=sh:et:ts=4:sw=4:tw=80
1008
1009 diff --git a/completions/euse b/completions/euse
1010 new file mode 100644
1011 index 0000000..e7bed0a
1012 --- /dev/null
1013 +++ b/completions/euse
1014 @@ -0,0 +1,60 @@
1015 +# Gentoo Linux Bash Shell Command Completion
1016 +#
1017 +# Copyright 1999-2013 Gentoo Foundation
1018 +# Distributed under the terms of the GNU General Public License, v2 or later
1019 +
1020 +source "@helpersdir@/gentoo-common.sh"
1021 +
1022 +_euse() {
1023 + local cur prev opts sopts use portdir
1024 + COMPREPLY=()
1025 + cur="${COMP_WORDS[COMP_CWORD]}"
1026 + prev="${COMP_WORDS[COMP_CWORD-1]}"
1027 + opts="-h --help -v --version -i --info -I --info-installed -a --active
1028 + -E --enable -D --disable -P --prune"
1029 + sopts="-g --global -l --local"
1030 +
1031 + if [[ ${cur} == -* ]] && [[ ${COMP_CWORD} -eq 1 ]] ; then
1032 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
1033 + return 0
1034 + fi
1035 +
1036 + case "${prev}" in
1037 + -h|--help|-v|--version)
1038 + COMPREPLY=()
1039 + ;;
1040 + -a|--active)
1041 + COMPREPLY=($(compgen -W "${sopts}" -- ${cur}))
1042 + ;;
1043 + -i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)
1044 + portdir=$(_portdir)
1045 + use="$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc) \
1046 + $(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)"
1047 + COMPREPLY=($(compgen -W "${use} ${sopts}" -- ${cur}))
1048 + ;;
1049 + *)
1050 + local l=0 g=0
1051 +
1052 + if [[ ${COMP_LINE} == *" "@(-l|--local)* ]] ; then
1053 + l=1
1054 + elif [[ ${COMP_LINE} == *" "@(-g|--global)* ]] ; then
1055 + g=1
1056 + fi
1057 +
1058 + if [[ ${COMP_LINE} == *" "@(-i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)* ]]
1059 + then
1060 + portdir=$(_portdir)
1061 +
1062 + if [[ ${l} -eq 1 ]] ; then
1063 + use=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
1064 + elif [[ ${g} -eq 1 ]] ; then
1065 + use=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
1066 + fi
1067 +
1068 + COMPREPLY=($(compgen -W "${use}" -- ${cur}))
1069 + fi
1070 + esac
1071 +} &&
1072 +complete -F _euse euse
1073 +
1074 +# vim: ft=sh:et:ts=4:sw=4:tw=80
1075
1076 diff --git a/completions/gcc-config b/completions/gcc-config
1077 new file mode 100644
1078 index 0000000..80e95c3
1079 --- /dev/null
1080 +++ b/completions/gcc-config
1081 @@ -0,0 +1,45 @@
1082 +# Gentoo Linux Bash Shell Command Completion
1083 +#
1084 +# Copyright 1999-2013 Gentoo Foundation
1085 +# Distributed under the terms of the GNU General Public License, v2 or later
1086 +
1087 +#
1088 +# gcc-config completion command
1089 +#
1090 +_gcc_config() {
1091 + local cur prev opts
1092 + COMPREPLY=()
1093 + cur="${COMP_WORDS[COMP_CWORD]}"
1094 + prev="${COMP_WORDS[COMP_CWORD-1]}"
1095 + opts="-O --use-old \
1096 + -P --use-portage-chost \
1097 + -c --get-current-profile \
1098 + -l --list-profiles \
1099 + -E --print-environ \
1100 + -B --get-bin-path \
1101 + -L --get-lib-path \
1102 + -X --get-stdcxx-incdir"
1103 +
1104 + if [[ "${cur}" == -* ]] ; then
1105 + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
1106 + return 0
1107 + elif [[ ${COMP_CWORD} -eq 1 ]] ; then
1108 + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) \
1109 + $(compgen -W "$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" \
1110 + -- ${cur}) )
1111 + return 0
1112 + fi
1113 +
1114 + case "${prev}" in
1115 + -O|--use-old|-P|--use-portage-chost|-c|--get-current-profile|-l|--list-profiles)
1116 + COMPREPLY=()
1117 + ;;
1118 + *)
1119 + COMPREPLY=( $(compgen -W "\
1120 + $(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) )
1121 + ;;
1122 + esac
1123 +} &&
1124 +complete -F _gcc_config gcc-config
1125 +
1126 +# vim: ft=sh:et:ts=4:sw=4:tw=80
1127
1128 diff --git a/completions/gentoo b/completions/gentoo
1129 deleted file mode 100644
1130 index 30a1eb1..0000000
1131 --- a/completions/gentoo
1132 +++ /dev/null
1133 @@ -1,1652 +0,0 @@
1134 -# Gentoo Linux Bash Shell Command Completion
1135 -#
1136 -# Copyright 1999-2013 Gentoo Foundation
1137 -# Distributed under the terms of the GNU General Public License, v2 or later
1138 -
1139 -source "@helpersdir@/gentoo-common.sh"
1140 -
1141 -#
1142 -# emerge completion command
1143 -#
1144 -_emerge()
1145 -{
1146 - local c cur prev curword numwords opts cond prepend
1147 - local words stophere i x
1148 - local action actionpos sysactions pkgpos
1149 - local portdir=$(_portdir -o)
1150 - COMPREPLY=()
1151 - cur="${COMP_WORDS[COMP_CWORD]}"
1152 - prev="${COMP_WORDS[COMP_CWORD-1]}"
1153 - numwords=${#COMP_WORDS[*]}
1154 - curword=${COMP_CWORD}
1155 - opts=''
1156 -
1157 - if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
1158 - COMPREPLY=($(compgen -f -- ${cur}))
1159 - return 0
1160 - fi
1161 -
1162 - # find action
1163 - for x in ${COMP_LINE} ; do
1164 - if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \
1165 - [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|regen|resume|search|sync|unmerge) ]]
1166 - then
1167 - action=${x}
1168 - break
1169 - fi
1170 - done
1171 -
1172 - if [[ -n ${action} ]]; then
1173 - for ((i = 0; i < ${numwords}; i++ )); do
1174 - if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
1175 - actionpos=${i}
1176 - pkgpos=$((actionpos + 1))
1177 - break
1178 - fi
1179 - done
1180 -
1181 - if [[ ${action} == -* && ${action} != --* ]] ; then
1182 - case "${action}" in
1183 - -*C*) action='--unmerge' ;;
1184 - -*P*) action='--prune' ;;
1185 - -*c*) action='--clean' ;;
1186 - -*s*) action='--search' ;;
1187 - esac
1188 - fi
1189 - else
1190 - for ((i = 1; i < ${numwords}; i++ )); do
1191 - if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
1192 - pkgpos=${i}
1193 - break
1194 - fi
1195 - done
1196 - [[ -z ${pkgpos} ]] && pkgpos=${numwords}
1197 - fi
1198 -
1199 - # Handle special cases.
1200 - if [[ ${action} == "--search" ]] || [[ ${COMP_LINE} == *" "-@(S|-searchdesc)* ]] || \
1201 - [[ ${COMP_LINE} == *" "-@(V|-version)* ]] || [[ ${action} == "--metadata" ]]
1202 - then
1203 - unset COMPREPLY
1204 - return 0
1205 - elif [[ ${COMP_LINE} == *" "-@(h|-help)* ]] ; then
1206 - unset COMPREPLY
1207 - [[ ${curword} -eq 2 ]] && COMPREPLY=($(compgen -W 'system world --sync' -- ${cur}))
1208 - return 0
1209 - fi
1210 -
1211 - # Complete on options.
1212 - if [[ ${cur} == -* ]]; then
1213 - # If a resume option was specified, it needs special handling.
1214 - if [[ ${COMP_LINE} =~ --(resume|skipfirst) ]] ; then
1215 - if [[ ${cur} == --* ]]; then
1216 - opts="--ask --pretend --resume --skipfirst"
1217 - elif [[ ${cur} == -* ]]; then
1218 - [[ ${COMP_LINE} =~ --(ask|pretend) ]] && opts="-a -p"
1219 - fi
1220 - elif [[ ${cur} == --* ]]; then
1221 - # Complete on long options.
1222 - opts="--alphabetical --ask \
1223 - --buildpkg --buildpkgonly \
1224 - --changelog --clean --color=y --color=n --columns --complete-graph --config \
1225 - --debug --deep --depclean \
1226 - --emptytree \
1227 - --fetch-all-uri --fetchonly \
1228 - --getbinpkg --getbinpkgonly \
1229 - --ignore-default-opts --info \
1230 - --jobs= \
1231 - --keep-going \
1232 - --metadata \
1233 - --newuse --noconfmem --nodeps --noreplace --nospinner \
1234 - --oneshot --onlydeps \
1235 - --pretend --prune \
1236 - --quiet \
1237 - --reinstall=changed-use --regen \
1238 - --search \
1239 - --sync \
1240 - --tree \
1241 - --unmerge --update --upgradeonly --usepkg --usepkgonly \
1242 - --verbose \
1243 - --with-bdeps=y --with-bdeps=n"
1244 - if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
1245 - opts="${opts} --help --resume --searchdesc --version"
1246 - fi
1247 - elif [[ ${cur} == -* ]]; then
1248 - # Complete on short options.
1249 - opts="-B -D -G -K -N -O -a -b -d -e -f -g -k -l -n -o -p -q -t -u -v"
1250 - if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
1251 - opts="${opts} -h -S -V"
1252 - fi
1253 - if [[ -z ${action} ]] && [[ ${curword} -eq $((pkgpos - 1)) ]] ; then
1254 - opts="${opts} -C -P -c -s"
1255 - fi
1256 - fi
1257 -
1258 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
1259 -
1260 - # NOTE: This slows things down!
1261 - # (Adapted from bash_completion by Ian Macdonald <ian@×××××××.org>)
1262 - # This removes any options from the list of completions that have
1263 - # already been specified on the command line.
1264 - COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
1265 - (while read -d ' ' i; do
1266 - [[ -z ${i} ]] && continue
1267 - # flatten array with spaces on either side,
1268 - # otherwise we cannot grep on word boundaries of
1269 - # first and last word
1270 - COMPREPLY=" ${COMPREPLY[@]} "
1271 - # remove word from list of completions
1272 - COMPREPLY=(${COMPREPLY/ ${i%% *} / })
1273 - done
1274 - echo ${COMPREPLY[@]})))
1275 -
1276 - return 0
1277 - fi # options
1278 -
1279 - # Stop completion if a special case is encountered.
1280 - if [[ ${action} =~ (system|world) ]] || \
1281 - [[ ${COMP_LINE} =~ --(depclean|metadata|regen|resume|skipfirst|sync) ]]
1282 - then
1283 - unset COMPREPLY
1284 - return 0
1285 - fi
1286 -
1287 - # Complete on installed packages when unmerging.
1288 - if [[ "${action}" == '--unmerge' ]]; then
1289 - if [[ -n "${cur}" ]] ; then
1290 - if [[ "${cur}" == */* ]]; then
1291 - words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")
1292 - else
1293 - words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -S '/' -G "${cur}*")
1294 -
1295 - local n=0
1296 - for i in ${words} ; do
1297 - [[ ${i} == ${cur}* ]] && n=$((n+1))
1298 - done
1299 -
1300 - if [[ ${n} -eq 1 ]] ; then
1301 - words="$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -G "*-*/*")"
1302 - fi
1303 - fi
1304 - COMPREPLY=($(for i in ${words} ; do \
1305 - [[ ${i} == ${cur}* ]] && echo ${i} ; \
1306 - done))
1307 - else
1308 - COMPREPLY=($(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -S '/' -G "*-*"))
1309 - fi
1310 -
1311 - [[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg
1312 - return 0
1313 - fi
1314 -
1315 - # Check for conditional.
1316 - cond="${cur%%[A-Za-z0-9]*}"
1317 - cur="${cur:${#cond}}"
1318 - if [[ ${cond:0:1} == "'" || ${cond:0:1} == '"' ]] ; then
1319 - prepend="-P ${cond:1}"
1320 - c="${cond:1}"
1321 - else
1322 - c="${cond}"
1323 - fi
1324 -
1325 - # Handle cases where a conditional is specified.
1326 - if [[ -n "${cond}" ]]; then
1327 - if [[ -n "${cur}" ]]; then
1328 - if [[ ${cur} == */* ]]; then
1329 - if [[ ${cur} == *-[0-9]* ]] ; then
1330 - words="$(\
1331 - for pd in ${portdir} ; do \
1332 - builtin cd ${pd} ; \
1333 - local cat="${cur%/*}" ; \
1334 - local pkg="$(echo ${cur%-[0-9]*})" ; \
1335 - pkg="${pkg##*/}" ; \
1336 - for x in ${cat}/${pkg}/*.ebuild ; do \
1337 - [[ -f ${x} ]] || continue ; \
1338 - x="${x/${pkg}\/}" ; \
1339 - echo "${x%*.ebuild}" ; \
1340 - done ; \
1341 - done)"
1342 - else
1343 - words="$(\
1344 - for pd in ${portdir} ; do \
1345 - builtin cd ${pd}; \
1346 - compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \
1347 - done)"
1348 - fi
1349 -
1350 - local w
1351 - for x in $words ; do
1352 - w="${x}\n${w}"
1353 - done
1354 -
1355 - words=$(echo -ne ${w} | sort | uniq)
1356 - COMPREPLY=( ${words} )
1357 -
1358 - # Complete on the specific versions (if appropriate).
1359 - # TODO - see if we can use _pkgname
1360 - if [[ ${#COMPREPLY[@]} -le 1 ]]; then
1361 - COMPREPLY=($(
1362 - for pd in ${portdir}; do
1363 - if [[ -d ${pd}/metadata/md5-cache ]]; then
1364 - builtin cd ${pd}/metadata/md5-cache
1365 - compgen ${prepend} -G "${cur}*" -- "${cur}"
1366 - elif [[ -d ${pd}/metadata/cache ]]; then
1367 - builtin cd ${pd}/metadata/cache
1368 - compgen ${prepend} -G "${cur}*" -- "${cur}"
1369 - else
1370 - builtin cd ${pd}
1371 - local cat="${cur%/*}"
1372 - local pkg="$(echo ${cur%-[0-9]*}*)"
1373 - pkg="${pkg##*/}"
1374 - for x in ${cat}/${pkg}/*.ebuild; do
1375 - [[ -f "${x}" ]] || continue
1376 - x="${x/${pkg}\/}"
1377 - if [[ ${cond:0:1} == "'" ]] || [[ ${cond:0:1} == '"' ]]; then
1378 - echo "${c}${x%*.ebuild}"
1379 - else
1380 - echo "${x%*.ebuild}"
1381 - fi
1382 - done
1383 - fi
1384 - done
1385 - ))
1386 - else
1387 - COMPREPLY=($(compgen ${prepend} -W "${words}" -- $cur))
1388 - fi
1389 - else
1390 - words="$(\
1391 - for pd in ${portdir} ; do \
1392 - builtin cd ${pd} ; \
1393 - compgen ${prepend} -S '/' -G "${cur}*" -- "${cur}" ; \
1394 - done)"
1395 -
1396 - local w
1397 - for x in words ; do
1398 - w="${x}\n${w}"
1399 - done
1400 -
1401 - COMPREPLY=($(echo -e ${w} | uniq))
1402 - [[ ${#COMPREPLY[@]} = 1 ]] && \
1403 - COMPREPLY=($(\
1404 - for pd in ${portdir} ; do \
1405 - builtin cd ${pd} ; \
1406 - compgen ${prepend} -G "${cur}*/*" -- "${cur}" ; \
1407 - done))
1408 - fi
1409 - else
1410 - words="$(\
1411 - for pd in ${portdir} ; do \
1412 - builtin cd ${pd}; \
1413 - compgen -G "*-*"; \
1414 - done)"
1415 - COMPREPLY=($(compgen -W "${words}" -- "${cur}"))
1416 - fi
1417 -
1418 - # If all else fails, try to complete on package names without the
1419 - # category being specified.
1420 - if [[ -z "${COMPREPLY}" ]]; then
1421 - words="$(\
1422 - for pd in ${portdir} ; do \
1423 - builtin cd ${pd}; \
1424 - for i in *-*/${cur}*; do \
1425 - [[ -d $i ]] && echo ${i##*/}; \
1426 - done ; \
1427 - done)"
1428 -
1429 - COMPREPLY=($(compgen ${prepend} -W "${words}" -- ${cur}))
1430 -
1431 - if [[ ${#COMPREPLY[@]} -le 1 ]]; then
1432 - # Now complete on the specific versions.
1433 - words="$(
1434 - for pd in ${portdir}; do
1435 - if [[ -d ${pd}/metadata/md5-cache ]]; then
1436 - builtin cd ${pd}/metadata/md5-cache
1437 - for i in */${cur}*; do
1438 - [[ -f $i ]] && echo ${i##*/}
1439 - done
1440 - elif [[ -d ${pd}/metadata/cache ]]; then
1441 - builtin cd ${pd}/metadata/cache
1442 - for i in */${cur}*; do
1443 - [[ -f $i ]] && echo ${i##*/}
1444 - done
1445 - fi
1446 - done
1447 - )"
1448 - COMPREPLY=($(compgen ${prepend} -W "${words}" -- "${cur}"))
1449 - fi
1450 - fi
1451 - return 0
1452 - fi
1453 -
1454 - # Complete on packages.
1455 - #
1456 - # Only allow these actions if no packages have been specified.
1457 - #
1458 - # TODO: This doesn't block these actions if no categories are
1459 - # specified. Please fix me.
1460 - #
1461 - # e.g. emerge -a gentoo-dev-sources
1462 - #
1463 - # will still allow system and world actions to be specified,
1464 - # as opposed to
1465 - #
1466 - # emerge -a sys-kernel/gentoo-dev-sources
1467 - #
1468 - if [[ ${COMP_CWORD} -eq 1 ]] || [[ ! " ${COMP_LINE} " == *" "*[/]*" "* ]] ; then
1469 - sysactions=$'\n'"system"$'\n'"world"
1470 - else
1471 - sysactions=''
1472 - fi
1473 -
1474 - if [[ -n "${cur}" ]] ; then
1475 - if [[ ${cur} == */* ]] ; then
1476 - words=$(\
1477 - for pd in ${portdir} ; do \
1478 - builtin cd ${pd}; \
1479 - compgen -X "*metadata.xml" -G "${cur}*" ; \
1480 - done)"${sysactions}"
1481 - else
1482 - local ww=$(\
1483 - for pd in ${portdir} ; do \
1484 - builtin cd ${pd} ; \
1485 - compgen -X "!@(*-*|virtual)" -S '/' -G "${cur}*"; \
1486 - done)"${sysactions}"
1487 - # complete on virtuals
1488 - ww="${ww} $(\
1489 - for pd in ${portdir} ; do \
1490 - if [[ -d ${pd}/profiles ]] ; then
1491 - find ${pd}/profiles -name virtuals -exec \
1492 - sed -n -e 's|^\(virtual/[[:alnum:]]\+\).*$|\1|p' {} \; | \
1493 - sort -u
1494 - fi ; \
1495 - done)"
1496 -
1497 - local w
1498 - for x in ${ww} ; do w="${x}\n${w}" ; done
1499 -
1500 - words=$(echo -e ${w} | sort -u)
1501 -
1502 - local n=0
1503 - for i in ${words} ; do
1504 - [[ ${i} == ${cur}* ]] && n=$((n+1))
1505 - done
1506 -
1507 - if [[ ${n} -eq 1 ]] ; then
1508 - words=$(for pd in ${portdir} ; do \
1509 - builtin cd ${pd} ; \
1510 - compgen -G "*-*/*" ; \
1511 - done)"${sysactions}"
1512 - fi
1513 - fi
1514 - COMPREPLY=($(for i in ${words} ; do \
1515 - [[ ${i} == ${cur}* ]] && echo ${i} ; \
1516 - done))
1517 - else
1518 - words="$(\
1519 - for pd in ${portdir} ; do \
1520 - builtin cd ${pd} ; \
1521 - compgen -S '/' -G "*-*" ; \
1522 - done)""${sysactions}"
1523 - COMPREPLY=($(compgen -W "${words}" -- ${cur}))
1524 - fi
1525 -
1526 - # If all else fails, try to complete on package names without the
1527 - # category being specified.
1528 - if [[ -z "${COMPREPLY}" ]]; then
1529 - words="$(\
1530 - for pd in ${portdir} ; do \
1531 - builtin cd ${pd}; \
1532 - for i in [a-z]*-[a-z0-9]*/${cur}*; do \
1533 - [[ -d $i ]] && echo ${i##*/}; \
1534 - done ; \
1535 - done)"
1536 - COMPREPLY=($(compgen -W "${words}" -- ${cur}))
1537 - fi
1538 -
1539 - return 0
1540 -} &&
1541 -complete -o filenames -F _emerge emerge
1542 -
1543 -#
1544 -# ebuild completion command
1545 -#
1546 -_ebuild()
1547 -{
1548 - local cur opts
1549 - COMPREPLY=()
1550 - cur="${COMP_WORDS[COMP_CWORD]}"
1551 -
1552 - opts="help setup clean fetch digest manifest unpack compile test preinst \
1553 - install postinst qmerge merge unmerge prerm postrm config package rpm \
1554 - configure prepare"
1555 -
1556 - if [[ $COMP_CWORD -eq 1 ]] ; then
1557 - COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) \
1558 - $(compgen -d -- ${cur}) \
1559 - $(compgen -W '--debug --force --help --ignore-default-opts --skip-manifest' -- ${cur}))
1560 -
1561 - elif [[ $COMP_CWORD -eq 2 && "${COMP_WORDS[1]}" = "--debug --force --ignore-default-opts --skip-manifest" ]] ; then
1562 - COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) $(compgen -d -- ${cur}))
1563 -
1564 - elif [[ $COMP_CWORD -ge 2 ]] ; then
1565 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
1566 - fi
1567 - return 0
1568 -} &&
1569 -complete -o filenames -F _ebuild ebuild
1570 -
1571 -#
1572 -# rc completion command
1573 -#
1574 -_rc()
1575 -{
1576 - local cur
1577 - COMPREPLY=()
1578 - cur="${COMP_WORDS[COMP_CWORD]}"
1579 - if [[ ${#COMP_WORDS[*]} -le 2 ]]; then
1580 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
1581 - fi
1582 - return 0
1583 -} &&
1584 -complete -F _rc rc
1585 -
1586 -#
1587 -# rc-status completion command
1588 -#
1589 -_rcstatus()
1590 -{
1591 - local cur
1592 - cur="${COMP_WORDS[COMP_CWORD]}"
1593 - if [[ $COMP_CWORD -eq 1 ]]; then
1594 - if [[ "${cur}" == --* ]]; then
1595 - COMPREPLY=($(compgen -W '--all --list --unused' -- ${cur}))
1596 - elif [[ "${cur}" == -* ]]; then
1597 - COMPREPLY=($(compgen -W '-a -l -u' -- ${cur}))
1598 - else
1599 - COMPREPLY=($(compgen -W "$(rc-status --list)" -- ${cur}))
1600 - fi
1601 - else
1602 - unset COMPREPLY
1603 - fi
1604 - return 0
1605 -} &&
1606 -complete -F _rcstatus rc-status
1607 -
1608 -#
1609 -# rc-update completion command
1610 -#
1611 -_rcupdate()
1612 -{
1613 - local cur show
1614 - COMPREPLY=()
1615 - cur="${COMP_WORDS[COMP_CWORD]}"
1616 - if [[ $COMP_CWORD -eq 1 ]]; then
1617 - if [[ "${cur}" == -* ]]; then
1618 - COMPREPLY=($(compgen -W '-a -d -s' -- ${cur}))
1619 - else
1620 - COMPREPLY=($(compgen -W 'add del show' ${cur}))
1621 - fi
1622 - else
1623 - if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then
1624 - show="TRUE"
1625 - fi
1626 - if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \
1627 - ([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]])
1628 - then
1629 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
1630 - elif [[ $COMP_CWORD -eq 2 ]]; then
1631 - COMPREPLY=($(compgen -X "*.@(c|sh|test)" -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/init.d/*; do echo ${i##*/}; done)" $cur))
1632 - elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then
1633 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
1634 - else
1635 - unset COMPREPLY
1636 - fi
1637 - fi
1638 - return 0
1639 -} &&
1640 -complete -F _rcupdate rc-update
1641 -
1642 -#
1643 -# gcc-config completion command
1644 -#
1645 -_gcc_config() {
1646 - local cur prev opts
1647 - COMPREPLY=()
1648 - cur="${COMP_WORDS[COMP_CWORD]}"
1649 - prev="${COMP_WORDS[COMP_CWORD-1]}"
1650 - opts="-O --use-old \
1651 - -P --use-portage-chost \
1652 - -c --get-current-profile \
1653 - -l --list-profiles \
1654 - -E --print-environ \
1655 - -B --get-bin-path \
1656 - -L --get-lib-path \
1657 - -X --get-stdcxx-incdir"
1658 -
1659 - if [[ "${cur}" == -* ]] ; then
1660 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
1661 - return 0
1662 - elif [[ ${COMP_CWORD} -eq 1 ]] ; then
1663 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) \
1664 - $(compgen -W "$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" \
1665 - -- ${cur}) )
1666 - return 0
1667 - fi
1668 -
1669 - case "${prev}" in
1670 - -O|--use-old|-P|--use-portage-chost|-c|--get-current-profile|-l|--list-profiles)
1671 - COMPREPLY=()
1672 - ;;
1673 - *)
1674 - COMPREPLY=( $(compgen -W "\
1675 - $(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) )
1676 - ;;
1677 - esac
1678 -} &&
1679 -complete -F _gcc_config gcc-config
1680 -
1681 -#
1682 -# distcc-config completion command
1683 -#
1684 -_distccconfig()
1685 -{
1686 - local cur curword numwords opts
1687 - COMPREPLY=()
1688 - cur="${COMP_WORDS[COMP_CWORD]}"
1689 - numwords=${#COMP_WORDS[*]}
1690 - curword=${COMP_CWORD}
1691 - if [[ ${numwords} -gt 3 ]]; then
1692 - unset COMPREPLY
1693 - return 0
1694 - fi
1695 - if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
1696 - if [[ ${numwords} -le 2 ]] && [[ ${curword} -eq 1 ]]; then
1697 - opts="--get-hosts \
1698 - --get-verbose \
1699 - --get-log \
1700 - --set-hosts \
1701 - --set-verbose \
1702 - --set-log \
1703 - --add-path \
1704 - --no-path"
1705 - else
1706 - opts=""
1707 - fi
1708 - else
1709 - opts=""
1710 - fi
1711 - COMPREPLY=($(compgen -W "${opts}" | grep ^$cur))
1712 - return 0
1713 -} &&
1714 -complete -F _distccconfig distcc-config
1715 -
1716 -#
1717 -# java-config completion command
1718 -#
1719 -_javaconfig()
1720 -{
1721 - local cur prev curword numwords opts args arg spec flag sedcmd grepcmd
1722 - local multiplepkgs pkgs execopts
1723 - COMPREPLY=()
1724 - cur="${COMP_WORDS[COMP_CWORD]}"
1725 - prev="${COMP_WORDS[COMP_CWORD-1]}"
1726 - numwords=${#COMP_WORDS[*]}
1727 - curword=${COMP_CWORD}
1728 - opts=""
1729 - args=""
1730 - pkgs=""
1731 - sedcmd="sed -r -e s/\[([^]]+)\].*/\1/"
1732 - vmsedcmd="sed -r -e s/\[([^]]+)\]/\1/"
1733 - grepcmd="egrep -o (--set-(system|user)-(classpath|vm)=)"
1734 - multiplepkgs=""
1735 - execopts="HtmlConverter JavaPluginControlPanel \
1736 - appletviewer awt_robot \
1737 - extcheck \
1738 - idlj \
1739 - j2sdk-config jar jarsigner \
1740 - java java-rmi.cgi java_vm javac javadoc javah javap jdb \
1741 - keytool kinit klist ktab \
1742 - native2ascii \
1743 - oldjava oldjavac oldjdb orbd \
1744 - policytool \
1745 - realpath rmic rmid rmiregistry \
1746 - serialver servertool \
1747 - tnameserv"
1748 - if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
1749 - case "${cur}" in
1750 - --java)
1751 - opts="--java --javac --java-version"
1752 - ;;
1753 - --j@(a@(r|va@(c|-version))|@(dk|re)-home))
1754 - opts=""
1755 - ;;
1756 - --list-available-@(packages|vms))
1757 - opts=""
1758 - ;;
1759 - --@(exec|set-@(user|system)-@(classpath|vm)))
1760 - opts="${cur}="
1761 - ;;
1762 - --set-@(user|system)-@(classpath|vm)=)
1763 - if [[ "${cur}" == "--set-system-vm=" ]] || [[ "${cur}" == "--set-user-vm=" ]]; then
1764 - flag="--list-available-vms"
1765 - args=$(java-config --nocolor "${flag}" | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
1766 - else
1767 - flag="--list-available-packages"
1768 - args=$(java-config --nocolor "${flag}" | ${sedcmd})
1769 - fi
1770 - for arg in ${args}; do
1771 - [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
1772 - done
1773 - COMPREPLY=($(compgen $nospace -W "${opts}"))
1774 - return 0
1775 - ;;
1776 - --exec=)
1777 - COMPREPLY=($(compgen $nospace -W "${execopts}"))
1778 - return 0
1779 - ;;
1780 - *)
1781 - if [[ "${cur}" == "--set-system-vm="* ]] || [[ "${cur}" == "--set-user-vm="* ]]; then
1782 - args=$(java-config --nocolor --list-available-vms | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
1783 - if [[ "${cur}" == "--set-system-vm="* ]]; then
1784 - spec=${cur##--set-system-vm=}
1785 - else
1786 - spec=${cur##--set-user-vm=}
1787 - fi
1788 - for arg in ${args}; do
1789 - if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
1790 - [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
1791 - fi
1792 - done
1793 - [[ "${opts}" == "${spec}" ]] && opts=""
1794 - COMPREPLY=($(compgen -W "${opts}"))
1795 - return 0
1796 - elif [[ "${cur}" == "--set-system-classpath="* ]] || [[ "${cur}" == "--set-user-classpath="* ]]; then
1797 - args=$(java-config --nocolor --list-available-packages | ${sedcmd})
1798 - [[ $(echo "${cur}" | grep -c ",") -gt 0 ]] && multiplepkgs="true"
1799 - if [[ "${cur}" == "--set-system-classpath="* ]]; then
1800 - spec="${cur##--set-system-classpath=}"
1801 - else
1802 - spec="${cur##--set-user-classpath=}"
1803 - fi
1804 - if [[ -n "${multiplepkgs}" ]]; then
1805 - pkgs="${spec%,*}"
1806 - spec="${spec##*,}"
1807 - fi
1808 - if [[ -n "${multiplepkgs}" ]]; then
1809 - for arg in ${args}; do
1810 - if [[ "${spec}" ]]; then
1811 - if [[ "${arg:0:${#spec}}" == "${spec}" ]] \
1812 - && [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]
1813 - then
1814 - [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
1815 - fi
1816 - else
1817 - if [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]; then
1818 - [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
1819 - fi
1820 - fi
1821 - done
1822 - [[ "${opts}" == "${pkgs},${spec}" ]] && opts=""
1823 - else
1824 - for arg in ${args}; do
1825 - if [[ "${spec}" ]] && [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
1826 - [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
1827 - fi
1828 - done
1829 - [[ "${opts}" == "${spec}" ]] && opts=""
1830 - fi
1831 - COMPREPLY=($(compgen -W "${opts}"))
1832 - return 0
1833 - elif [[ "${cur}" == "--exec="* ]]; then
1834 - spec=${cur##--exec=}
1835 - for arg in ${execopts}; do
1836 - if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
1837 - [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
1838 - fi
1839 - done
1840 - [[ "${opts}" == "${spec}" ]] && opts=""
1841 - COMPREPLY=($(compgen -W "${opts}"))
1842 - return 0
1843 - else
1844 - opts="--classpath --clean-system-classpath --clean-user-classpath \
1845 - --exec \
1846 - --full-classpath \
1847 - --jar --java --javac --java-version --jdk-home --jre-home \
1848 - --list-available-packages --list-available-vms \
1849 - --nocolor \
1850 - --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
1851 - [[ "$prev" == "--nocolor" ]] && opts="${opts/--nocolor}"
1852 - fi
1853 - ;;
1854 - esac
1855 - elif [[ "$prev" == "--nocolor" ]] && [ ${curword} -eq 2 ] && [ $numwords -le 3 ]; then
1856 - opts="--classpath --clean-system-classpath --clean-user-classpath \
1857 - --exec \
1858 - --full-classpath \
1859 - --jar --java --javac --java-version --jdk-home --jre-home \
1860 - --list-available-packages --list-available-vms \
1861 - --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
1862 - fi
1863 - COMPREPLY=($(compgen $nospace -W "${opts}" -- ${cur}))
1864 - return 0
1865 -} &&
1866 -complete $nospace -F _javaconfig java-config
1867 -
1868 -#
1869 -# browser-config completion command
1870 -#
1871 -_browserconfig()
1872 -{
1873 - local cur prev
1874 - COMPREPLY=()
1875 - cur="${COMP_WORDS[COMP_CWORD]}"
1876 - prev="${COMP_WORDS[COMP_CWORD-1]}"
1877 - if [[ ${COMP_CWORD} -eq 1 ]]; then
1878 - COMPREPLY=($(compgen -W '-b -h -m' -- ${cur}))
1879 - elif [[ "${prev}" == "-b" ]]; then
1880 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/usr/share/browser-config/*; do [ -f $i ] && echo ${i##*/}; done)" $cur))
1881 - elif [[ "${prev}" == "-m" ]]; then
1882 - COMPREPLY=($(compgen -W "same_window new_window new_tab new_browser" -- ${cur}))
1883 - if [[ -z "${COMPREPLY}" ]]; then
1884 - COMPREPLY=''
1885 - fi
1886 - else
1887 - unset COMPREPLY
1888 - fi
1889 - return 0
1890 -} &&
1891 -complete -F _browserconfig browser-config
1892 -
1893 -#
1894 -# Bash completion for the Gentoo 'equery' command
1895 -#
1896 -_equery()
1897 -{
1898 - local cur prev mode portdir i j
1899 - portdir=$(_portdir)
1900 - mode="GLOBAL"
1901 - COMPREPLY=()
1902 - cur="${COMP_WORDS[COMP_CWORD]}"
1903 - prev="${COMP_WORDS[COMP_CWORD-1]}"
1904 - # Find out what we're currently doing here.
1905 - j=0
1906 - for i in "${COMP_WORDS[@]}"; do
1907 - if [[ $j -lt $COMP_CWORD ]]; then
1908 - j=$((j + 1))
1909 - case $i in
1910 - @(belongs|ch@(anges|eck)|dep@(ends|graph)|files|has?(use)|keywords|list|meta|size|uses|which|b|c|k|d|g|f|a|h|y|l|m|s|u|w))
1911 - mode=$i
1912 - ;;
1913 - esac
1914 - fi
1915 - done
1916 - # Now get to work.
1917 - case $mode in
1918 - GLOBAL)
1919 - # Complete commands and global options.
1920 - case $cur in
1921 - -*)
1922 - COMPREPLY=($(compgen -W "-q --quiet -C --nocolor -h --help -V --version" -- $cur))
1923 - ;;
1924 - *)
1925 - COMPREPLY=($(compgen -W "belongs changes check depends depgraph files has hasuse keywords list meta size uses which" -- $cur))
1926 - ;;
1927 - esac
1928 - ;;
1929 - c?(hanges))
1930 - # Complete package name only if it is not yet supplied.
1931 - if [[ ${prev} == ${mode} ]]; then
1932 - case $cur in
1933 - -*)
1934 - COMPREPLY=($(compgen -W "-h --help" -- $cur))
1935 - ;;
1936 - *)
1937 - _pkgname -A $cur
1938 - ;;
1939 - esac
1940 - else
1941 - case $cur in
1942 - *)
1943 - COMPREPLY=($(compgen -W "-h --help -l --latest -f --full --limit --from --to" -- $cur))
1944 - ;;
1945 - esac
1946 - fi
1947 - ;;
1948 - f?(iles))
1949 - # Only complete if the previous entry on the command line is not
1950 - # a package name.
1951 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
1952 - # --filter=<list>: completion of the files types list
1953 - if [[ ${prev} == "-f" || "${cur}" == "--filter="* ]] ; then
1954 - COMPREPLY=($(_list_compgen "${cur#--filter=}" , \
1955 - dir,obj,sym,dev,fifo,path,conf,cmd,doc,man,info))
1956 - return 0
1957 - fi
1958 - case $cur in
1959 - --f*)
1960 - # don't handle --filter= with others to avoid space after the "="
1961 - COMPREPLY=($(compgen -P "--filter=" \
1962 - -W "dir obj sym dev fifo path conf cmd doc man info"))
1963 - ;;
1964 - -*)
1965 - COMPREPLY=($(compgen -W "-h --help -m --md5sum -s --timestamp -t
1966 - --type --tree -f --filter=" -- $cur))
1967 - ;;
1968 - *)
1969 - # Only installed packages can have their files listed.
1970 - _pkgname -I $cur
1971 - ;;
1972 - esac
1973 - fi
1974 - ;;
1975 - a|has)
1976 - COMPREPLY=($(compgen -W "-h --help -I --exclude-installed -o \
1977 - --overlay-tree -p --portage-tree -F --format" -- $cur))
1978 - ;;
1979 - y|keywords)
1980 - # Only complete if the previous entry on the command line is not
1981 - # a package name.
1982 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
1983 - case "${cur}" in
1984 - -*)
1985 - COMPREPLY=($(compgen -W "-h --help -v --version -a --arch -A
1986 - --align -T --top-position -B --bold -C --color -O --overlays
1987 - -P --prefix -S --ignore-slot" -- $cur))
1988 - ;;
1989 - *)
1990 - _pkgname -A $cur
1991 - ;;
1992 - esac
1993 - fi
1994 - ;;
1995 - l?(ist))
1996 - # Only complete if the previous entry on the command line is not
1997 - # a package name.
1998 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
1999 - case "${cur}" in
2000 - -*)
2001 - COMPREPLY=($(compgen -W "-h --help -d --duplicates -b
2002 - --binpkgs-missing -f --full-regex -m --mask-reason -I
2003 - --exclude-installed -o --overlay-tree -p --portage-tree -F
2004 - --format" -- $cur))
2005 - ;;
2006 - *)
2007 - if [[ ${COMP_WORDS[@]} =~ -(p|o) || ${COMP_WORDS[@]} =~ --(portage|overlay)-tree ]]; then
2008 - _pkgname -A $cur
2009 - else
2010 - _pkgname -I $cur
2011 - fi
2012 - ;;
2013 - esac
2014 - fi
2015 - ;;
2016 - b?(elongs))
2017 - # Only complete if the previous entry on the command line is not
2018 - # a file name.
2019 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2020 - case $cur in
2021 - -*)
2022 - COMPREPLY=($(compgen -W "-h --help -f --full-regex -e
2023 - --early-out -n --name-only" -- $cur))
2024 - ;;
2025 - *)
2026 - COMPREPLY=($(compgen -f -- $cur) \
2027 - $(compgen -d -S '/' -- $cur))
2028 - ;;
2029 - esac
2030 - fi
2031 - ;;
2032 - u?(ses))
2033 - # Only complete if the previous entry on the command line is not
2034 - # a package name.
2035 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2036 - case $cur in
2037 - -*)
2038 - COMPREPLY=($(compgen -W "-h --help -a --all" -- $cur))
2039 - ;;
2040 - *)
2041 - # Complete on all package names.
2042 - _pkgname -A $cur
2043 - ;;
2044 - esac
2045 - fi
2046 - ;;
2047 - w?(hich))
2048 - # Only complete if the previous entry on the command line is not
2049 - # a package name.
2050 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2051 - case $cur in
2052 - -*)
2053 - COMPREPLY=($(compgen -W "-h --help -m --include-masked" -- $cur))
2054 - ;;
2055 - *)
2056 - # Complete on all package names.
2057 - _pkgname -A $cur
2058 - ;;
2059 - esac
2060 - fi
2061 - ;;
2062 - g|depgraph)
2063 - # Only complete if the previous entry on the command line is not
2064 - # a package name.
2065 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2066 - case $cur in
2067 - -*)
2068 - COMPREPLY=($(compgen -W "-h --help -A --no-atom -M --no-mask -U
2069 - --no-useflags -l --linear --depth" -- $cur))
2070 - ;;
2071 - *)
2072 - # Complete on all package names.
2073 - _pkgname -A $cur
2074 - ;;
2075 - esac
2076 - fi
2077 - ;;
2078 - d?(epends))
2079 - # Only complete if the previous entry on the command line is not
2080 - # a package name.
2081 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2082 - case $cur in
2083 - -*)
2084 - COMPREPLY=($(compgen -W "-h --help -a --all-packages -D
2085 - --indirect --depth" -- $cur))
2086 - ;;
2087 - *)
2088 - case $prev in
2089 - -a|--all-packages)
2090 - # Complete on all package names.
2091 - _pkgname -A $cur
2092 - ;;
2093 - *)
2094 - # Complete on installed package names.
2095 - _pkgname -I $cur
2096 - ;;
2097 - esac
2098 - ;;
2099 - esac
2100 - fi
2101 - ;;
2102 - m?(eta))
2103 - # Only complete if the previous entry on the command line is not
2104 - # a package name.
2105 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2106 - _equery_meta $cur
2107 - fi
2108 - ;;
2109 - k|check)
2110 - # Only complete if the previous entry on the command line is not
2111 - # a package name.
2112 - if [[ ${prev} == ${mode} ]]; then
2113 - case $cur in
2114 - -*)
2115 - COMPREPLY=($(compgen -W "${COMPREPLY[@]} -h --help -f
2116 - --full-regex -o --only-failures" -- ${cur}))
2117 - ;;
2118 - *)
2119 - # Only installed packages can have their integrity verified.
2120 - _pkgname -I $cur
2121 - ;;
2122 - esac
2123 - fi
2124 - ;;
2125 - s?(ize))
2126 - # Only complete if the previous entry on the command line is not
2127 - # a package name.
2128 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2129 - case $cur in
2130 - -*)
2131 - COMPREPLY=($(compgen -W "-h --help -b --bytes -f
2132 - --full-regex" -- $cur))
2133 - ;;
2134 - *)
2135 - # Only installed packages can have their size calculated.
2136 - _pkgname -I $cur
2137 - ;;
2138 - esac
2139 - fi
2140 - ;;
2141 - h?(asuse))
2142 - # Only complete if the previous entry on the command line is not
2143 - # a package name.
2144 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2145 - case $cur in
2146 - -*)
2147 - COMPREPLY=($(compgen -W "--help -i --installed -I --exclude-installed -p --portage-tree -o --overlay" -- $cur))
2148 - ;;
2149 - *)
2150 - local glob loc
2151 - [[ -f ${portdir}/profiles/use.desc ]] || return 0
2152 - [[ -f ${portdir}/profiles/use.local.desc ]] || return 0
2153 - glob=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
2154 - loc=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
2155 - COMPREPLY=($(compgen -W "$glob $loc" -- $cur))
2156 - ;;
2157 - esac
2158 - fi
2159 - ;;
2160 - esac
2161 - return 0
2162 -} &&
2163 -complete -F _equery equery
2164 -
2165 -#
2166 -# epkginfo completion
2167 -#
2168 -
2169 -_epkginfo()
2170 -{
2171 - local cur prev
2172 - cur="${COMP_WORDS[COMP_CWORD]}"
2173 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2174 -
2175 - # Only complete if the previous entry on the command line is not
2176 - # a package name.
2177 - if [[ ${COMP_CWORD} -eq 1 || ${prev:0:1} == "-" ]]; then
2178 - _equery_meta $cur
2179 - fi
2180 -
2181 - return 0
2182 -} &&
2183 -complete -F _epkginfo epkginfo
2184 -
2185 -#
2186 -# ekeyword completion
2187 -#
2188 -
2189 -_ekeyword()
2190 -{
2191 - local cur portdir archl_s archl_u archl_r archl_m arch
2192 - COMPREPLY=()
2193 - cur="${COMP_WORDS[COMP_CWORD]}"
2194 - portdir=$(_portdir)
2195 -
2196 - [[ -f ${portdir}/profiles/arch.list ]] || return 0
2197 -
2198 - for arch in all $(< ${portdir}/profiles/arch.list) ; do
2199 - archl_m="${archl_m} -${arch}"
2200 - archl_u="${archl_u} ~${arch}"
2201 - archl_r="${archl_r} ^${arch}"
2202 - archl_s="${archl_s} ${arch}"
2203 - done
2204 -
2205 - case ${cur} in
2206 - -*)
2207 - COMPREPLY=($(compgen -W "${archl_m}" -- ${cur}))
2208 - ;;
2209 - ~*)
2210 - COMPREPLY=($(compgen -W "${archl_u}" -- ${cur}))
2211 - ;;
2212 - ^*)
2213 - COMPREPLY=($(compgen -W "${archl_r}" -- ${cur}))
2214 - ;;
2215 - *)
2216 - COMPREPLY=($(compgen -W "${archl_s}" -- ${cur}))
2217 - _filedir 'ebuild'
2218 - ;;
2219 - esac
2220 -} &&
2221 -complete -o filenames -F _ekeyword ekeyword
2222 -
2223 -#
2224 -# portageq completion
2225 -#
2226 -
2227 -_portageq() {
2228 - local cur prev opts
2229 - COMPREPLY=()
2230 - cur="${COMP_WORDS[COMP_CWORD]}"
2231 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2232 -
2233 - opts="config_protect_mask \
2234 - config_protect \
2235 - vdb_path \
2236 - gentoo_mirrors \
2237 - all_best_visible \
2238 - match \
2239 - best_visible \
2240 - mass_best_visible \
2241 - has_version \
2242 - portdir \
2243 - envvar \
2244 - mass_best_version \
2245 - best_version \
2246 - pkgdir \
2247 - portdir_overlay \
2248 - distdir"
2249 -
2250 - if [[ $COMP_CWORD -eq 1 ]] ; then
2251 - # would always be correct, but it's pretty slow...
2252 - #COMPREPLY=($(compgen -W "$(portageq | grep '^ [[:lower:]]' | \
2253 - # sed -e 's/^.*[[:space:]]\([[:lower:]_]\+\)[[:space:]].*$/\1/')" \
2254 - # -- ${cur}))
2255 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
2256 - fi
2257 -
2258 - case "${prev}" in
2259 - config*|vdb_path|gentoo_mirrors|*dir*)
2260 - COMPREPLY=()
2261 - ;;
2262 -
2263 - # this also isn't the fastest, but I welcome an alternative method
2264 - envvar)
2265 - COMPREPLY=($(compgen -W "$(env -i emerge -v --info | \
2266 - sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur}))
2267 - ;;
2268 -
2269 - *v@(isible|ersion)|match)
2270 - COMPREPLY=($(compgen $nospace -W '/' -- $cur))
2271 - ;;
2272 -
2273 - # $prev is a path, so complete on category/package
2274 - */*)
2275 - local x a=0
2276 - for x in ${COMP_WORDS[@]} ; do
2277 - # This is the only one
2278 - if [[ "${x}" == "all_best_visible" ]] ; then
2279 - a=1
2280 - break
2281 - fi
2282 - done
2283 -
2284 - if [[ ${a} -eq 1 ]] ; then
2285 - COMPREPLY=()
2286 - else
2287 - # Check for conditional.
2288 -# cond="${cur%%[A-Za-z0-9]*}"
2289 -# cur="${cur:${#cond}}"
2290 -
2291 -# if [[ -n "${cond}" ]] ; then
2292 -# _pkgname -A $cur
2293 -# else
2294 - _pkgname -A $cur
2295 -# fi
2296 - fi
2297 - ;;
2298 - esac
2299 -} &&
2300 -complete -F _portageq portageq
2301 -
2302 -#
2303 -# webapp-config completion
2304 -#
2305 -
2306 -_webapp_complete_appver()
2307 -{
2308 - local x proot ibase cur="$2"
2309 - eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
2310 - echo proot="${MY_PERSISTROOT:-@GENTOO_PORTAGE_EPREFIX@/var/db/webapps}" ; \
2311 - echo ibase="${WA_INSTALLSBASE:-installs}")
2312 -
2313 - case "$1" in
2314 - # complete on installed
2315 - installed)
2316 - COMPREPLY=($(compgen -W "$(\
2317 - for x in ${proot}/*/*/installs ; do \
2318 - if [[ -f "${x}" ]] ; then \
2319 - local y="${x%/*}" ; \
2320 - y="${y%/*}" ; \
2321 - echo "${y##*/}" ; \
2322 - fi ; \
2323 - done)" -- ${cur}))
2324 - ;;
2325 -
2326 - # complete on uninstalled
2327 - uninstalled)
2328 - COMPREPLY=($(compgen -W "$(\
2329 - for x in ${proot}/*/* ; do \
2330 - if [[ ! -f "${x}/${ibase}" ]] ; then \
2331 - local y="${x%/*}" ; \
2332 - echo "${y##*/}" ; \
2333 - fi ; \
2334 - done)" -- ${cur}))
2335 - ;;
2336 -
2337 - # all
2338 - all)
2339 - COMPREPLY=($(compgen -W "$(\
2340 - for x in ${proot}/* ; do \
2341 - [[ -d "${x}" ]] && echo "${x##*/}" ; \
2342 - done)" -- ${cur}))
2343 - ;;
2344 -
2345 - # complete on version
2346 - *)
2347 - [[ -d "${proot}/$1" ]] || return 1
2348 - COMPREPLY=($(compgen -W "$(\
2349 - for x in ${proot}/$1/* ; do \
2350 - [[ -d "${x}" ]] && echo "${x##*/}" ; \
2351 - done)" -- ${cur}))
2352 - ;;
2353 - esac
2354 -}
2355 -
2356 -_webapp_config()
2357 -{
2358 - local cur prev actions opts hostroot
2359 - COMPREPLY=()
2360 - cur="${COMP_WORDS[COMP_CWORD]}"
2361 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2362 -
2363 - actions="-I --install -U --upgrade -C --clean --list-installs \
2364 - --list-unused-installs --show-installed --show-postinst \
2365 - --help -v --version"
2366 - opts="--bug-report --pretend -p -u --user -g --group \
2367 - -d --dir -h --host -V --verbose --soft --secure --virtual-dirs \
2368 - --virtual-files --force-virtual"
2369 -
2370 - eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
2371 - echo hostroot="${VHOST_ROOT:-@GENTOO_PORTAGE_EPREFIX@/var/www}")
2372 -
2373 - # --bug-report, --pretend, and -p can only be used as first arg
2374 - if [[ ${COMP_CWORD} -gt 1 ]] ; then
2375 - opts="${opts/--bug-report --pretend -p}"
2376 - fi
2377 -
2378 - if [[ "${cur}" == -* ]] || [[ ${COMP_CWORD} -eq 1 ]] ; then
2379 - COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
2380 - return 0
2381 - fi
2382 -
2383 - case "${prev}" in
2384 - --bug-report|-p|--pretend)
2385 - COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
2386 - ;;
2387 -
2388 - -I|--install)
2389 - _webapp_complete_appver all ${cur}
2390 - ;;
2391 -
2392 - -U|--upgrade)
2393 - _webapp_complete_appver installed ${cur}
2394 - ;;
2395 -
2396 - # only complete on -d since it is required if -C is specified
2397 - -C|--clean)
2398 - COMPREPLY=($(compgen -W "-d" -- ${cur}))
2399 - ;;
2400 -
2401 - --list-unused-installs)
2402 - _webapp_complete_appver uninstalled ${cur}
2403 - ;;
2404 -
2405 - --list-installs|--show-postinst)
2406 - _webapp_complete_appver all ${cur}
2407 - ;;
2408 -
2409 - # hrm... anyone know a better way to reliably do this?
2410 - -h|--host)
2411 - local x
2412 - COMPREPLY=($(compgen -W "$(\
2413 - for x in ${hostroot}/* ; do \
2414 - [[ -d "${x}" ]] && echo "${x##*/}" ; \
2415 - done)" -- ${cur}))
2416 - ;;
2417 -
2418 - --virtual*)
2419 - COMPREPLY=($(compgen -W "server-owned config-owned virtual" \
2420 - -- ${cur}))
2421 - ;;
2422 -
2423 - -d|--dir)
2424 - local host x i=0
2425 - # see if --host has been specified, and if so, get the value
2426 - # that was passed to it.
2427 - for x in ${COMP_WORDS[@]} ; do
2428 - if [[ "${x}" == "-h" || "${x}" == "--host" ]] ; then
2429 - host="${COMP_WORDS[((i+1))]}"
2430 - break
2431 - fi
2432 - i=$((i+1))
2433 - done
2434 -
2435 - # otherwise, use the default host
2436 - if [[ "${host}" == "" ]] ; then
2437 - eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
2438 - echo host="${VHOST_HOSTNAME:-localhost}")
2439 - fi
2440 -
2441 - COMPREPLY=($(compgen -W "$(\
2442 - for x in ${hostroot}${host}/* ; do \
2443 - [[ -d "${x}" ]] && echo "${x}" ; \
2444 - done)" -- ${cur}))
2445 - ;;
2446 - -u|--user)
2447 - COMPREPLY=($(compgen -u -- ${cur}))
2448 - ;;
2449 - -g|--group)
2450 - COMPREPLY=($(compgen -g -- ${cur}))
2451 - ;;
2452 -
2453 - # we haven't recognized it yet, so more than likely ${prev}
2454 - # is a 'app-name' ; assuming it is indeed a valid 'app-name'
2455 - # (_webapp_complete_appver does the check), complete on available
2456 - # 'app-version's
2457 - *)
2458 - _webapp_complete_appver ${prev} ${cur} || \
2459 - _webapp_complete_appver all ${cur}
2460 - ;;
2461 - esac
2462 -} &&
2463 -complete -F _webapp_config webapp-config
2464 -
2465 -_revdep_rebuild() {
2466 - local cur prev numwords opts
2467 - local words i x
2468 - local action actionpos
2469 - COMPREPLY=()
2470 - cur="${COMP_WORDS[COMP_CWORD]}"
2471 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2472 - numwords=${#COMP_WORDS[*]}
2473 -
2474 - if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
2475 - COMPREPLY=($(compgen -f -- ${cur}))
2476 - return 0
2477 - fi
2478 -
2479 - # find action
2480 - for ((i = 0; i < ${numwords}; i++ )); do
2481 - case ${COMP_WORDS[${i}]} in
2482 - --library|-L)
2483 - action=${COMP_WORDS[${i}]}
2484 - actionpos=${i}
2485 - ;;
2486 - --help|-h)
2487 - action=${COMP_WORDS[${i}]}
2488 - actionpos=${i}
2489 - ;;
2490 - esac
2491 - done
2492 -
2493 - if [[ ${cur} == -* ]]; then
2494 - if [[ ${cur} == --* ]]; then
2495 - opts="--exact --help --ignore --keep-temp --library --nocolor --no-ld-path --no-order --no-progress --no-util --pretend --quiet --verbose"
2496 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
2497 - else
2498 - opts="-e -h -i -k -L -l -o -p -P -q -u -v"
2499 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
2500 - fi
2501 - return 0
2502 - fi
2503 - if [[ ${action} == '--library' ]] || [[ ${action} == '-L' ]] ; then
2504 - if [[ "${cur}" == */* ]]; then
2505 - COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -f -- "${cur}") )
2506 - else
2507 - COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -X '/' -f -- "${cur}") )
2508 - fi
2509 - fi
2510 - return 0
2511 -} &&
2512 -complete -F _revdep_rebuild revdep-rebuild
2513 -
2514 -_splat() {
2515 - local cur prev opts
2516 - COMPREPLY=()
2517 - cur="${COMP_WORDS[COMP_CWORD]}"
2518 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2519 - opts="-h --help -v --verbose -s --summary -f --logfile -c --colored -l
2520 - --list -u --count -p --package -t --sort -r --reverse"
2521 -
2522 - if [[ ${cur} == -* ]] ; then
2523 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
2524 - return 0
2525 - fi
2526 -
2527 - case "${prev}" in
2528 - -f|--logfile)
2529 - COMPREPLY=($(compgen -f -- ${cur}))
2530 - ;;
2531 - *)
2532 - _pkgname -A ${cur}
2533 - COMPREPLY=($(compgen -W "${COMPREPLY[@]} ${opts}" -- ${cur}))
2534 - ;;
2535 - esac
2536 -} &&
2537 -complete -o filenames -F _splat splat
2538 -
2539 -_euse() {
2540 - local cur prev opts sopts use portdir
2541 - COMPREPLY=()
2542 - cur="${COMP_WORDS[COMP_CWORD]}"
2543 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2544 - opts="-h --help -v --version -i --info -I --info-installed -a --active
2545 - -E --enable -D --disable -P --prune"
2546 - sopts="-g --global -l --local"
2547 -
2548 - if [[ ${cur} == -* ]] && [[ ${COMP_CWORD} -eq 1 ]] ; then
2549 - COMPREPLY=($(compgen -W