Closed
Description
When I try the autocomplete feature in bash with file names that contain spaces, the completion fails, because the parts of the name are treated separately.
So if I have a file named file with spaces.txt
and type fi
, then nothing happens on first TAB (despite no other file matches fi
), and on the second TAB I get the list: file spaces.txt with
as possible completions, which is the correctly found filename, but the parts sorted alphabetically.
It looks for me like the result of some missing quotes or something like that, but I know very few of bash autocompletion, so I don't know how to fix it.
Metadata
Metadata
Assignees
Labels
No labels
Activity
jonasvertikal commentedon Oct 31, 2024
I believe a solution for Bash could be to replace
from the completion generator with
using the approach by https://stackoverflow.com/a/26511572. This appears to properly format paths with spaces.
It does, however, introduce a dependency on mapfile which is builtin since Bash 4 from 2009.
Unintended splits on spaces is also an issue for custom completion (source).
Here's a minimal example that shows the issue:
A similar solution for Bash could be to replace
from here with
Support spaces in bash completion file names (ajalt#576)