Some builtin bash completions don't work for files/directories with spaces.
See Bug 417717 for more details.
I have this problem on a current stable amd64 system since the completions were updated to the new 'all enabled' version.
For example with 'cd': having two dirs to possibly descend to
$ cd H
gets completed to
$ cd Harry
and adding '-' can be completed to Harry-Potter. Adding space like '\ ' can _not_ be completed!
The completion works when the filename is started with a single quote:
$ cd 'Harry
can be completed after adding a space.
The exact same completions work without problems for 'rm' and other commands.
Can anyone point to which file provides the completions for builtins? Would also be good to see an example of how to fix. I don't care so much about the more esoteric commands, but having broken 'cd' is really hard to cope with.
I'm not sure exactly if this is the proper way to fix this issue, but if this can help, here is what I did:
in function _filedir, I changed :
_quote_readline_by_ref "$cur" quoted
- x=$( compgen -d -- "$cur" ) &&
+ x=$( compgen -d -- "$quoted" ) &&
while read -r tmp; do
toks+=( "$tmp" )
Trying to find where the issue came from, I found that compgen -d does not seem to handle well quoted/escaped strings.
compgen -f does (hence, rm completion works, because it does not call "_filedir -d"), so this could be an issue with bash's builtin itself.
Again, as this was my first look at bash-completion, I'm not sure this is the way to go, the only thing I can tell, is that now, things complete as they used to and I haven't found any negative impact of my (recent though) change.
and of course, patch in my comment is backward.
I replaced "$quoted" by "$cur" :-)
The fix described in comments #3/4 seems to work. At least the moments of me hitting TAB and being perplexed by nothing happening tend towards zero now. :-) Thanks for sharing your fix!
I consistently hit this bug for trying to "cd" into directories with spaces in the names.
I confirm that I hit this bug on at least two different systems, and that Pascal's patch from comment #3 does correct the trouble.
I can no longer reproduce this with app-shells/bash-completion-2.1_p20141224-r1, which means the fix for #543100 has probably fixed this as well.
same here : all fixed, can not reproduce after bash-completion update either.
Confirmed too, although the upstream does include Pascal's patch, and NOT the gentoo used one. Unsure which is best.
Alright folks. Thanks a lot for confirming the patch we put in fixed this issue. Let's close this bug and move on then. :)