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
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.
Chet
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:
<http://en.opensuse.org/openSUSE:Mailing_list_netiquette>
diff -rup bash-4.2.orig/bashline.c bash-4.2/bashline.c
--- bash-4.2.orig/bashline.c 2012-02-29 10:28:32.196236258 +0100
+++ bash-4.2/bashline.c 2012-02-29 12:57:15.071591691 +0100
@@ -2722,7 +2722,7 @@ set_directory_hook ()
if (dircomplete_expand)
{
rl_directory_completion_hook = bash_directory_completion_hook;
- rl_directory_rewrite_hook = (rl_icppfunc_t *)0;
+ rl_directory_rewrite_hook = bash_directory_completion_hook;
}
else
{