[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Filename completion causes doubling of initial ':' character
From: |
Chet Ramey |
Subject: |
Re: Filename completion causes doubling of initial ':' character |
Date: |
Sat, 3 Dec 2016 11:44:55 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 |
On 12/3/16 6:41 AM, Ravi (Tom) Hale wrote:
> Bash Version: 4.4
> Patch Level: 5
> Release Status: release
>
>
> Description:
> ------------
> Given a filename called ':example'
> When the user enters 'command :' and hits <tab>
> Then the completion of the filename gets a doubled colon, specifically:
> ':\:example'
>
>
> Repeat-By:
> ----------
> Create a filename beginning with a ':' character:
>
> $ touch :example
>
> Type `rm :` and hit tab, then enter.
>
> I'd expect to see:
>
> rm :example
> [rm silently deletes it]
This has come up many times over the years. Here's one from 2003:
http://lists.gnu.org/archive/html/bug-bash/2003-01/msg00088.html
Question E13 in the Bash FAQ answers it.
The short answer is that colon is special to readline: it breaks words for
the readline completion code. If you want to complete filenames beginning
with a colon, either quote the colon or remove colon from $COMP_WORDBREAKS.
If you're using bash-completion, it may have its own problems with colons.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/