Created attachment 965414 [details] Screencast for the behavior reported in this bug Description of problem: If I have 2 dir, say Axyz and "A B C", I cant do "cd A\ <tab>" or even "A\ B<tab>"to reach "A B C" ...the tab completion is not working. If there is no other directory starting with "A", its working fine. Version-Release number of selected component (if applicable): 3.14 How reproducible: Always Steps to Reproduce: 1. Have 2 or more directory starting with same initial (A here) and one of them having space in its name("A B C") 2. in gnome terminal, press A\ B<tab> 3. Actual results: Nothing happenning Expected results: bash autocomplete should take you to "A\ B\ C" dir Additional info: I have attached a screencast to show this. Unfortunately, I have no way to capture keys, so, you have to trust me that I am really pressing <tab>
this has nothing to do with gnome-terminal. completion is entirely up the shell
Hi, thanks for the report. Could you please specify the versions of your bash and bash-completion packages? Thanks
bash-4.3.33-1.fc21.x86_64 bash-completion-2.1-6.20141110git52d8316.fc21.noarch There's a long-ish discussion of this on the debian bugtracker: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=740971
*** Bug 1171496 has been marked as a duplicate of this bug. ***
Today I checked a bit more. This seems to be, as from debian's bug suggest by Ralf, its due to bash-completion. From bash-completion trouble-shooting, i did: $set -v $ls A\words=("${@:3:2}") cword="$3" cur="$3" cur="$3" cword="$3" prev="$3" words=("${@:3:2}")
Bash 4.2 tab works. Bash 4.3 tab is broken. Native auto-completion (Alt+/) works on both versions.
As noted in comment 5, this is a bug in bash-completion.
Created attachment 985686 [details] bash-completition _cd patch This is fixed for me by using the attached patch. The problem may be in another area, but I'm not very familiar with bash-completion.
Created attachment 985710 [details] bash-completition _cd patch 2 The same problem happens with mkdir and rmdir since it goes through the same function option '-d'.
I can confirm that removing "-d" from line 1616 solves the problem, as suggested by Michael
Replacing _filedir -d with plain _filedir is wrong because then we will end up offering filenames as completions where we want dir names only (that's what the -d there signifies). Additionally, the patch is far from complete. # grep -R "_filedir -d" /usr/share/bash-completion | wc -l 229 (that's counting symlinks too, but anyway) This needs to be fixed by getting _filedir -d working properly with bash 4.3.
I never suggested my patch was complete. I agree the '-d' option must be fixed, or if may end up being the wrong option for these few cases.
Created attachment 992781 [details] bash-completion patch v3 The problem is the _quote_readline_by_ref function. It escapes any escapes because it calls printf with %q. The double-escaped string is passed to compgen -d and the "-d" option to compgen does not match directories with escapes like the "-f" option does. If I add a eval line to undo any escapes before calling the _quote_readline_by_ref function tab completion works as expected. This patch should be a possible, proper fix.
So it might be a bug in bash-4.3, however if I comment out the inclusion of /etc/bashrc from my .bashrc file, bash-4.3 works as expected. So something /etc/bashrc is 'enabling' the bug. (keypresses enclosed in []s) bash-4.3$ mkdir Axyz bash-4.3$ mkdir "A B C" bash-4.3$ cd A[tab][tab] A B C/ Axyz/ bash-4.3$ cd A[\][space][tab]\ B\ C/[enter] bash-4.3$ pwd /tmp/A B C bash-4.3$
i.e., # .bashrc # Source global definitions #if [ -f /etc/bashrc ]; then # . /etc/bashrc #fi
It is not a bash bug. Your bashrc enables bash-completion and during that process it disables bash's native auto-completion and enables it's own auto-completion. See bash-completion patch v3 if you want to fix your system.
Thanks a bunch for looking into this! I do however still have some reservations about this patch: What we have reported is a problem with filedir -d, however the patch changes things also for non -d _filedir completions and I'd rather not go there at all unless we do have some evidence that there is a bug to be fixed in those completions as well. Second, we already have the unquoted version of $cur around, no need to unquote it again. So the patch would simplify to this: diff --git a/bash_completion b/bash_completion index 24b6aa6..6eca58c 100644 --- a/bash_completion +++ b/bash_completion @@ -570,3 +570,3 @@ _filedir() _quote_readline_by_ref "$cur" quoted - x=$( compgen -d -- "$quoted" ) && + x=$( compgen -d -- "$cur" ) && while read -r tmp; do This seems to fix the reported problem and does not cause any new test suite failures with bash 4.3.33 nor any regressions with bash 4.2.53 as far as I see, so I've pushed this along with a test case upstream. http://anonscm.debian.org/cgit/bash-completion/bash-completion.git/commit/?id=d2920b7e79e5f347fed064b2a5aa952ef200e615
It would not have affected other usage as compgen -f didn't care about double escapes, but I just encountered a failure when using escape-required characters other than a space. The upstream patch looks complete. Thanks.
It's maybe not quite as simple as that, I mean the escaping/quoting mess must be there for a reason. The reason might be related to some older versions of bash we no longer support (for example the _filedir commentary is clearly outdated) but this is such a can of worms that I don't want to touch it unless something's demonstrably broken and a related test case can be added for it.
*** Bug 1179227 has been marked as a duplicate of this bug. ***
*** Bug 1202078 has been marked as a duplicate of this bug. ***
*** Bug 1215362 has been marked as a duplicate of this bug. ***
Ville, will we see a package update so you can stop closing duplicates?
Yes. I'd rather do it via a new upstream release which I've been asking for for quite some time now, but it hasn't happened yet.
bash-completion-2.1-6.20150513git1950590.fc22 has been submitted as an update for Fedora 22. https://admin.fedoraproject.org/updates/bash-completion-2.1-6.20150513git1950590.fc22
Still seeing the bug with bash-completion-2.1-6.20150513git1950590.fc22 mkdir "A B C" cd A\ [tab][tab] nothing happens.
GAH, the package forgot to apply the fix /etc/bash_completion.d/redefine_filedir in addition to the main location. redefine_filedir exists only in this package, not in an upstream setup such as mine which is why it worked for me and in upstream test suite. Updated update, go try it out and leave karma how it looks now: https://admin.fedoraproject.org/updates/bash-completion-2.1-7.20150513git1950590.fc22
bash-completion-2.1-7.20150513git1950590.fc22 works! I'm not seeing the bug any more. Thanks!
Could you also push a F21 update? That's what the original report was from. Thanks, Ville.
Package bash-completion-2.1-7.20150513git1950590.fc22: * should fix your issue, * was pushed to the Fedora 22 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=updates-testing bash-completion-2.1-7.20150513git1950590.fc22' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-2015-8232/bash-completion-2.1-7.20150513git1950590.fc22 then log in and leave karma (feedback).
bash-completion-2.1-7.20150513git1950590.fc21 has been submitted as an update for Fedora 21. https://admin.fedoraproject.org/updates/bash-completion-2.1-7.20150513git1950590.fc21
bash-completion-2.1-7.20150513git1950590.fc21 has been pushed to the Fedora 21 stable repository. If problems still persist, please make note of it in this bug report.
bash-completion-2.1-7.20150513git1950590.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.