[Bash-completion-devel] [Bash-completion-commits] [SCM] bash-completion branch, master, updated. cbf7e1f96387bdccdc965e5ed49de58b7dfceeef

Freddy Vulto fvulto at gmail.com
Fri Dec 11 21:38:47 UTC 2009


On 091210 15:55, Todd Zullinger wrote:
> Freddy Vulto wrote:
> > On 091209 22:25, Guillaume Rousse wrote:
> >> Why doesn't remove the colon from COMP_WORDBREAKS works with bash
> >> 3?
> >
> > COMP_WORDBREAKS is a bash-4 variable, see:
> >
> >    http://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html
> >
> > Bash-3 always splits command line words using a fixed set of
> > wordbreak-characters, I thinks it's: " \t\n\"'><=;|&(:", and it
> > can't be modified...
> 
> Sure it can.  The same text from the bash manual link above is present
> in the bash-3.2 documentation.  I don't know how far back it goes,
> though it's not mentioned in the one bash-2.05b man page I have at
> hand.

Hmm, my mistake, the solution of:

    COMP_WORDBREAKS=${COMP_WORDBREAKS//:}

indeed works on bash-3 as well.  It turns out the effect of modifying
COMP_WORDBREAKS is twofold and I only noticed the first on bash-4:
1.  COMP_WORDS is split by COMP_WORDBREAKS-characters (bash-4 only)
2.  CWORD (cur) is right-trimmed up to the first COMP_WORDBREAKS-character.

For example, with:

    _a() { 
        echo; printf "<%s> " "${COMP_WORDS[@]}"
        COMPREPLY=( foo1 foo2 )
    }
    complete -F _a a

This is what I get on bash-4.0.33:

    $ COMP_WORDBREAKS=${COMP_WORDBREAKS}:
    $ a b:c<TAB>
    <a> <b> <:> <c>    # (1) Split at :
    foo1  foo2
    $ a b:foo^C        # (2) `c' is right-trimmed
    $ COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
    $ a b:c<TAB>
    <a> <b:c>          # (1) No more split at :
    foo1  foo2
    $ a foo            # (2) No right-trim 

On bash-3.2.29, only the right-trim is done:

    $ COMP_WORDBREAKS=${COMP_WORDBREAKS}:
    $ a b:c<TAB>
    <a> <b:c>          # (1) No split at :
    foo1  foo2
    $ a b:foo^C        # (2) `c' is right-trimmed
    $ COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
    $ a b:c<TAB>
    <a> <b:c>          # (1) No split at :
    foo1  foo2
    $ a foo            # (2) No right-trim


Let's continue the discussion on the thread "Completion words containing
colons"?


Regards,

Freddy Vulto
http://fvue.nl



More information about the Bash-completion-devel mailing list