[Bash-completion-devel] Colon completion woes

Freddy Vulto fvulto at gmail.com
Mon May 10 17:36:02 UTC 2010


On 100510 10:16, Guillaume Rousse wrote:
> Bash is treating ':' as a special character, starting a new completion
> each time. See item E13 in http://tiswww.case.edu/php/chet/bash/FAQ

Yes, and we worked around the colon (:) issue with _known_hosts_real, by
calling __ltrim_colon_completions at the end.  You can fix the `wol'
behaviour by calling `__ltrim_colon_completions' at the end of
`_mac_addresses'.

See also the comment above __ltrim_colon_completions:

# If the word-to-complete contains a colon (:), left-trim COMPREPLY
# items with word-to-complete.
# On bash-3, and bash-4 with a colon in COMP_WORDBREAKS, words
# containing colons are always completed as entire words if the word to
# complete contains a colon.  This function fixes this, by removing the
# colon-containing-prefix from COMPREPLY items.
# The preferred solution is to remove the colon (:) from COMP_WORDBREAKS
# in your .bashrc:
#
#    # Remove colon (:) from list of word completion separators
#    COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
#
# See also: Bash FAQ - E13) Why does filename completion misbehave if a
# colon appears in the filename? -
# http://tiswww.case.edu/php/chet/bash/FAQ

Actually I think we should *always* call __ltrim_colon_completions just
before returning COMPREPLY...  Maybe we should start thinking about
adding a begin and end hook to every completion for things like this;
put it at the end of the roadmap?


Greetings,

Freddy Vulto
http://fvue.nl



More information about the Bash-completion-devel mailing list