You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since commit da99bc5, completions are no longer built by joining together the result of compgen -f -X ... and compgen -d; instead, -o plusdirs is used.
The problem is that the quoted ref we're trying to complete won't complete directory names, only filenames. Test case:
$ mkdir -p "foo bar"/{one,two} && touch "foo bar"/{file1.txt,one/file2.txt}
$ compgen -f -X '!*.@(@(TXT|txt))' -o plusdirs -- foo\\\ bar/
foo bar/file1.txt
$ compgen -f -X '!*.@(@(TXT|txt))' -o plusdirs -- "foo bar/"
foo bar/file1.txt
foo bar/two
foo bar/one
# if the final directory ending in "/" has no spaces, it works
$ compgen -f -X '!*.@(@(TXT|txt))' -o plusdirs -- foo\\\ bar/one/
foo bar/one/file2.txt
# if there is no -X $xspec then it works
$ compgen -f -o plusdirs -- foo\\\ bar/
foo bar/file1.txt
foo bar/two
foo bar/one
I'm not sure why bash returns results this way, or whether it's also a bash bug, but it's currently impossible to descend into subdirectories of a directory with spaces in the name when using a _filedir $xspec.
Tested on Arch Linux with bash-completion 2.10-1 and bash 5.0.011-2, and verified by running compgen against bash 3 and 4 via shbot on Freenode, so if bash is doing wrong here, it seems like it has for an awful long time.
The text was updated successfully, but these errors were encountered:
I'm curious why these escapes even exist. If I replace the variable $quoted with $cur, then my original _filedir using completion works fine as per example 2. What utility does the \\\ add?
I have no idea offhand, and quite probably not even after looking at the code. It's entirely possible that the reasoning is a relic from bash 2.x times and hasn't mattered for a long time.
I've contemplated just stopping using _filedir altogether and deprecating it for a bunch of times already, as I don't even remember what good does it actually bring when it works properly, and it has its quirks. But every time I've considered, something (which escapes me at the moment, too) has prevented me from doing that.
Anyway, it's pretty clear already that any further changes to it must come with a bunch of test cases.
hramrach
added a commit
to hramrach/bash-completion
that referenced
this issue
Sep 30, 2021
…all for files"
This reverts commit da99bc5.
References: scop#378 boo#1167952
The solution without calling compgen -d proves unrealiable.
Until this is fixed revert to calling compgen -d for completions with
file pattern.
Since commit da99bc5, completions are no longer built by joining together the result of
compgen -f -X ...
andcompgen -d
; instead, -o plusdirs is used.The problem is that the quoted ref we're trying to complete won't complete directory names, only filenames. Test case:
I'm not sure why bash returns results this way, or whether it's also a bash bug, but it's currently impossible to descend into subdirectories of a directory with spaces in the name when using a
_filedir $xspec
.Tested on Arch Linux with bash-completion 2.10-1 and bash 5.0.011-2, and verified by running compgen against bash 3 and 4 via shbot on Freenode, so if bash is doing wrong here, it seems like it has for an awful long time.
The text was updated successfully, but these errors were encountered: