[Bash-completion-devel] Completion words containing colons

Freddy Vulto fvulto at gmail.com
Wed Dec 9 21:28:50 UTC 2009

There's a problem when completion words containing colons (:).  For example,
when you do this in an empty directory:

   $ touch abc:def
   $ rm abc:<TAB>  # Becomes: abc:abc\:def (see also *1)

The solution for bash-4 is to remove the colon from COMP_WORDBREAKS (see also


The workaround for bash-3 - or bash-4 with a colon in COMP_WORDBREAKS - is to

   __ltrim_colon_completions "$cur"

after completions have been put in COMPREPLY.

Regarding the bash-4 solution, are we going to put this advice in the
documention or do we remove the colon from COMP_WORDBREAKS in bash-completion?
I think I'm in favour of the advice.

Regarding the workaround, __ltrim_colon_completions() can be called *always*,
but we don't have a hook in bash-completion yet for calling functions at the
end of a completion?  Are we going to wait for the bash-completion-lib merge to
call __ltrim_colon_completions() at the of completions?  If so, I'll put it on
the roadmap, and just apply __ltrim_colon_completions() where the problem
surfaces - so far being:
- _known_hosts_real()
- _perlmodules()

*1)  Bug report #377935: completion of ':' mangles filename

*2)  E13) Why does filename completion misbehave if a colon appears in the
     filename? - Bash FAQ


Freddy Vulto

More information about the Bash-completion-devel mailing list