[Bash-completion-devel] Get stuck

Igor Murzov e-mail at date.by
Sun May 22 23:45:39 UTC 2011


Hey! I get stuck trying to implement completion script for strings containing 
two parts for completion delimited by '%' sign.  For example, `cmd opt%arg`. 
The problem is that, if i hit tab key, when cursor is behind delimeter, bash 
eats first part of string leaving `cmd arg`. I just can't understand why, for 
example `cmd -opt=arg` works just fine, and `cmd opt%arg` is not. What is the 
difference?

I also wrote the simple script to demonstrate the issue:
---------------------------------------------------------
_zz()
{
    COMPREPLY=()
    local cur="${COMP_WORDS[COMP_CWORD]}"
    if [[ "$cur" == ?*%* ]]; then
        cur="${cur#*%}"
        COMPREPLY=( $( compgen -W 'abc bbb cde' -- "$cur" ) )
        return 0
    fi

    compopt -o nospace
    COMPREPLY=( $(compgen -W 'xxx yyy zzz' -- "$cur") )
} && complete -F _zz zz
---------------------------------------------------------

'_init_completion -n %' does not solve the issue either.

-- Igor



More information about the Bash-completion-devel mailing list