bug-bash
[Top][All Lists]
Advanced

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

Re: Oddities when tab-completing filenames containing backticks


From: Chet Ramey
Subject: Re: Oddities when tab-completing filenames containing backticks
Date: Fri, 16 Oct 2009 23:41:45 -0400
User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)

address@hidden wrote:

> Bash Version: 4.0
> Patch Level: 39
> Release Status: release
> 
> Description:
>    
>    Also affects Bash 4.0.33.
>    
>    When a filename begins with a backtick ` then tab-completion works
>    as expected if you go \`<tab>, however if you try to tab-complete
>    the filename inside single quotes, several strange behaviours appear.

You need to remember that readline understands the characters in
rl_completer_quote_characters as those which, in pairs, delimit quoted
substrings in the line.  It performs completion (allowing the application
to take first crack, of course) on the substring, using the text after
the open quote.

The other thing to keep in mind is that readline doesn't look past point
when performing completion -- it only considers characters from the
beginning of the line or a quote character up to point.

My answers below are for the built-in bash completion, not any programmable
completions you might have defined.

> Repeat-By:
> 
>    1) '`<tab>      This causes all commands available on the system to be
>                    listed such as `awk `bash etc., even though it's inside
>                    single quotes.

Readline does completion on substrings; it passes ` to the bash completion
code, which performs command completion.

> 
>    2) '`text<tab>  This completes the filename, but it does not insert a
>                    trailing single quote as tab-completion would usually do.

Bash receives "`text", does command completion on `text' and suppresses
the append of the close quote, since it's usually wrong in this case.

>    3) '`dir<tab>   This completes the directory name and adds the trailing
>                    forward slash, but not the trailing single quote.

Again, appending the trailing single quote without the trailing ` is
generally going to be wrong.

>    4) 'text`<tab>  This completes the filename and closes the single quote
>                    as expected.

Interesting.  I don't get this behavior.

>    5) '`text<tab>' When using tab-completion inside single quotes on a
>                    filename beginning with a backtick, then it completes
>                    the filename and adds an additional closing single quote,
>                    e.g. '`filename.txt''

Also interesting.  I get normal command completion without any closing
quote appended.

>    6) '`dir<tab>'  When using tab-completion inside single quotes on a
>                    directory name beginning with a backtick, then it
>                    completes the directory name and adds an additional
>                    closing single quote after the directory name and before
>                    the forward slash, e.g. '`directory'/'

I don't see this behavior either.

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]