bug-bash
[Top][All Lists]
Advanced

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

Re: bash tab variable expansion question?


From: Chet Ramey
Subject: Re: bash tab variable expansion question?
Date: Sun, 27 Feb 2011 18:18:24 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7

On 2/27/11 8:39 AM, Clark J. Wang wrote:
> On Sat, Feb 26, 2011 at 10:49 PM, gnu.bash.bug 
> <michael.kalisz@gmail.com>wrote:
> 
>>
>> Wow...I'ts good workaround:
>>
>> $ cd /tmp
>> $ echo ~+
>> /tmp
>>
>> Thanks Andreas!
>>
>>
> A workaround is fine but is the 4.2 behavior bug or not?

It's a more-or-less unintended consequence of the requested change Eric
Blake referred to earlier in the thread.

Bash-4.1 expanded shell variables in filename completion both internally
and externally: it had to expand the directory name internally so it knew
the correct directory name to pass to opendir(); and it used the same
expansion externally, making the expanded directory name part of the
completed filename it inserted into the line.  When readline is completing
filenames, and there are characters in the expanded filename that are
contained in the value of the rl_completer_quote_characters, readline
quotes the filename before inserting it.  Since the filename was
expanded, any special characters appearing in it were part of the filename
read from the file system and should be quoted.

Bash-4.2 performs the same internal expansion, but keeps the directory name
the user typed in the filename it inserts into the command line.  The `$'
is quoted because it's a character bash treats specially, and it needs to
be quoted when it appears as part of what readline thinks is a filename.

The question is how to tell readline that the `$' should be quoted under
some circumstances but not others.  There's no hard-and-fast rule that
works all the time, though I suppose a call to stat(2) before quoting
would solve part of the problem.  I will have to give it more thought.

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



reply via email to

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