[Top][All Lists]

[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: Fri, 02 Sep 2011 15:32:43 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1

On 2/24/11 5:14 PM, Michael Kalisz wrote:

> Bash Version: 4.2
> Patch Level: 0
> Release Status: release
> Description:
> Hi!
> Example:
> In bash, version 4.1.5(1)-release:
> $ echo $PWD/<TAB>
> will expand the $PWD variable to your current directory
> while in bash, version 4.2.0(1)-release:
> $ echo $PWD/<TAB>
> will just escape the $ in front of the $ variable i.e:
> $ echo \$PWD/
> The shell-expand-line (Ctrl-Alt-e) works but before I could use just TAB
> Any hints why? Any way to get the 4.1 behavior in 4.2?

I wrote, in a subsequent message in a related thread:

> The difference is that bash-4.1 expanded $HOME and left the expansion
> as part of the replacement text.  Bash-4.2 tries to leave what the
> user typed alone, but that leads to an inherently ambiguous situation:
> when do you quote the `$' in a filename (or, in this case, a directory
> name)?  It could be a shell variable, and it could be a character in
> the filename.

That is the problem, in a nutshell.  I posted a partial patch at the
end of March that applied a heuristic to avoid quoting variable
expansions in most cases, but there was no way to get the bash-4.1
behavior back.

The attached patch adds a new shell option that, when enabled, is
intended to restore the bash-4.1 behavior of expanding directory names
in filenames being completed.  I have done some testing, and it seems
to work the way I intend.  This, or some later version, will be part
of the next bash release.  I am soliciting feedback on this iteration.

I'm sending this directly to everyone who's commented negatively about
the default bash-4.2 behavior, as well as bug-bash.  Please try the new
option (`direxpand') and let me know if it's missing anything.  The patch
includes the original heuristic I sent out back in March, the new shopt
option, and updates to the documentation and test suite.  It should apply
cleanly to bash-4.2.10.

``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/

Attachment: direxpand-patch
Description: Text document

reply via email to

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