help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Different completion behavior for ':' when there are oth


From: Chet Ramey
Subject: Re: [Help-bash] Different completion behavior for ':' when there are other files or not
Date: Thu, 09 May 2013 16:42:46 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130328 Thunderbird/17.0.5

On 5/9/13 12:00 AM, Peng Yu wrote:
> Hi,
> 
> In /tmp/a, there is only ':', but nothing else.
> 
> /tmp/a$ mkdir :
> /tmp/a$ cd :<TAB>
> 
> The command completion of the above one becomes the following (which
> is not correct).
> 
> /tmp/a$ cd :\:/

It's not that unexpected if you think about what's going on.  First, `:'
is one of the characters that splits words for the readline completion
code.  (That list of characters is in $COMP_WORDBREAKS.)  That means
that the word being completed is "".  When there is a single file in the
directory, that (`:') is returned as the one completion.  The `:' is
quoted because the colon is special to the completion code, as explained
above, and bash needs to distinguish it so that it does not break words.
The trailing slash is probably added by your completion function; I don't
get that when running bash without any completions defined.


> But if I create an addition file, then the command completion of 'cd
> :<TAB>' will work correctly.
> /tmp/a$ touch xxx.txt

`Correctly', I assume, means that nothing happens.  The same null word
completion happens as above, but there are multiple possible completions
so nothing is added to the line.

This has come up in the past.  Read the thread at

http://lists.gnu.org/archive/html/bug-bash/2011-02/msg00163.html

for a sample.

In short, there isn't a bug, and there isn't anything mysterious happening
aside from whatever the completion function may be doing.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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