On 2/27/11 8:39 AM, Clark J. Wang wrote: > On Sat, Feb 26, 2011 at 10:49 PM, gnu.bash.bug > <michael.kal...@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 c...@case.edu http://cnswww.cns.cwru.edu/~chet/