[Top][All Lists]

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

Re: bash tab variable expansion question?

From: Sebastian Siebert
Subject: Re: bash tab variable expansion question?
Date: Mon, 05 Mar 2012 20:07:16 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120215 Thunderbird/10.0.2

Am 02.09.2011 21:32, schrieb Chet Ramey:
On 2/24/11 5:14 PM, Michael Kalisz wrote:

Bash Version: 4.2
Patch Level: 0
Release Status: release




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.


Hi Chet,

Thanks for the great patch.

I have applied your patch in our bash 4.2 + Patchlevel 20. It is solved an issue with variable expansion. But on the other side bash completion is broken. :-(

Bash completion with local file (./some_script.sh, e.g.) would not be working:

# ./some_sc <TAB>

Current result:
# ./some_sc

Expected result:
# ./some_script.sh

It seems that the bash completion stops working.

I have added another patch to fix this issue. It would be nice if you have a look to the patch and let me know if this is ok.

Thank you.

Kind regards, Sebastian - openSUSE Member (Freespacer)
Website/Blog: <http://www.sebastian-siebert.de>
Important notes on openSUSE Mailing List:

Attachment: direxpand_fixed_stop_completion.patch
Description: Text Data

reply via email to

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