Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 47849 - bash-completion - /etc/bash_completion.d/gentoo improvement
Summary: bash-completion - /etc/bash_completion.d/gentoo improvement
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All All
: High enhancement (vote)
Assignee: Christian Birchinger (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-14 15:12 UTC by Peter Ruskin
Modified: 2004-04-18 08:43 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Ruskin 2004-04-14 15:12:44 UTC
Suggested patch for /etc/bash_completion.d/gentoo: (@ line 591 onwards)
_openglupdate()
{
        local cur opts
+     # opts already defined but not used
+        opts=\'$(ls /usr/lib/opengl)\'
        COMPREPLY=()
        cur=${COMP_WORDS[COMP_CWORD]}
        numwords=${#COMP_WORDS[*]}
        if [ ${numwords} -gt 2 ]; then
                return 0
        fi
+        COMPREPLY=($(compgen -W $opts $cur))
-#       COMPREPLY=($(compgen -W 'nvidia xfree' $cur))
        COMPREPLY=($(echo " ${COMP_WORDS[@]}" | \
                (while read -d ' ' i; do
                        [ "$i" == "" ] && continue
                        # flatten array with spaces on either side,
                        # otherwise we cannot grep on word
                        # boundaries of first and last word
                        COMPREPLY=" ${COMPREPLY[@]} "
                        # remove word from list of completions
                        COMPREPLY=( ${COMPREPLY/ $i / })
                done
                echo ${COMPREPLY[@]})))
        return 0
}
complete -F _openglupdate opengl-update
Comment 1 Christian Birchinger (RETIRED) gentoo-dev 2004-04-18 08:13:55 UTC
I'll use the following line since $opts would be only used once
And external commands like 'ls' shouldn't be used in bash-completion
if theres a simple solution using internal bash functions.

COMPREPLY=($(compgen -W "$(for i in /usr/lib/opengl/*; do echo ${i##*/}; done)" $cur))

Comment 2 Christian Birchinger (RETIRED) gentoo-dev 2004-04-18 08:28:09 UTC
I think this would do the job much simpler:

_openglupdate()
{
        local cur
        COMPREPLY=()
        cur=${COMP_WORDS[COMP_CWORD]}
        if [ ${#COMP_WORDS[*]} -le 2 ]; then
                COMPREPLY=($(compgen -W "$(for i in /usr/lib/opengl/*; do [ -d "$i" ] && echo ${i##*/}; done)" $cur))
        fi
        return 0
}
complete -F _openglupdate opengl-update
Comment 3 Christian Birchinger (RETIRED) gentoo-dev 2004-04-18 08:43:17 UTC
Function changed in CVS