OK, that explains the problem, and I have a workaround. (Background: I have a personal tool that uses "foo:bar" syntax for some of its arguments. I've modified the tool to use "foo/bar instead.)
Escaping the colons with backslashes doesn't seem to work: $ echo $BASH_VERSION 5.2.32(1)-release $ echo $COMP_WORDBREAKS "'@><=;|&(: $ say() { echo "$@" ; } $ complete -r $ complete -W "abc\:abc abc\:xyz" say $ complete complete -W 'abc\:abc abc\:xyz' say $ say abc:abc:abc:abc:abc: # hitting TAB multiple times abc:abc:abc:abc:abc: $ On Mon, Dec 2, 2024 at 11:51 AM Chet Ramey <chet.ra...@case.edu> wrote: > > On 12/2/24 12:52 AM, Keith Thompson wrote: > > > Bash Version: 5.2 > > Patch Level: 32 > > Release Status: release > > > > Description: > > If the wordlist given to `complete -W` includes words > > containing the ':' character, completion misbehaves. > > > > The problem seems to occur if two or more words in the wordlist > > share a common prefix ending with ':'. The problem does not > > occur with other characters; I've tried '/' and '_'. > > This is from the (obsolete) FAQ (doc/FAQ): > > E13) Why does filename completion misbehave if a colon appears in the > filename? > > Filename completion (and word completion in general) may appear to behave > improperly if there is a colon in the word to be completed. > > The colon is special to readline's word completion code: it is one of the > characters that breaks words for the completer. Readline uses these > characters > in sort of the same way that bash uses $IFS: they break or separate the words > the completion code hands to the application-specific or default word > completion functions. The original intent was to make it easy to edit > colon-separated lists (such as $PATH in bash) in various applications using > readline for input. > > This is complicated by the fact that some versions of the popular > `bash-completion' programmable completion package have problems with the > default completion behavior in the presence of colons. > > The current set of completion word break characters is available in bash as > the value of the COMP_WORDBREAKS variable. Removing `:' from that value is > enough to make the colon not special to completion: > > COMP_WORDBREAKS=${COMP_WORDBREAKS//:} > > You can also quote the colon with a backslash to achieve the same result > temporarily. > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/