Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to implement a custom bash completion as described here. However, it seems that compgen is case-sensitive. Is there a way to turn it case-insensitive in that context ?

share|improve this question
add comment

1 Answer 1

I would modify the example from the link you mentioned into something like this:

_foo() 
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD],,}"     # this downcases the result
    prev="${COMP_WORDS[COMP_CWORD-1],,}"  # here too
    opts="--help --verbose --version"

    if [[ ${cur} == -* ]] ; then
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
    fi
}
complete -F _foo foo

For more info refer to the bash documentation or the bash hackers site.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.