bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TAB completion of filenames beginning with colon is broken


From: Chet Ramey
Subject: Re: TAB completion of filenames beginning with colon is broken
Date: Thu, 13 Jun 2019 15:11:48 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

On 6/13/19 2:56 AM, Jason Tyler wrote:

> Bash Version: 5.0
> Patch Level: 3
> Release Status: release
> 
> Description:
> if a filename begins with ":", then tab completion will turn the colon into
> ":\:"

This is a pretty old question, old enough to have its own entry in the
no-longer-updated bash 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    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]