bash-completion icon indicating copy to clipboard operation
bash-completion copied to clipboard

Filename completion on unquoted string

Open mmjo opened this issue 1 year ago • 1 comments

Describe the bug

File completion when there is an open quote fails. I.e. "a b"/"x<TAB>

To reproduce

mkdir empty cd empty mkdir d touch d/f

  1. cd empty
  2. Type: d/"<TAB>
  3. Get: d/"d/f"

Expected behavior

Get: d/f Or: d/"f"

Versions (please complete the following information)

  • [X] Ubuntu 22.04.3 LTS / Linux 6.2.0-33-generic #33~22.04.1-Ubuntu
  • [X] bash version: 5.1.16(1)-release
  • [X] bash-completion version: 2.11

Additional context

Initially the problem occurred with spaces in directory and filenames. Hence the typing of the " before the <TAB>.

Discussion in bug-readline mailing list, especially the message of the bash/readline maintainer, Chet Ramey: https://lists.gnu.org/archive/html/bug-readline/2023-09/msg00018.html

Debug trace

trace.txt

mmjo avatar Sep 28 '23 21:09 mmjo

Chet Ramey notes further (https://lists.gnu.org/archive/html/bug-readline/2023-10/msg00000.html):

This could be an opportunity for bash-completion to do a better job than bash's default completion.

It could note that ${COMP_WORDS[$COMP_CWORD]} differs from the word readline thinks is being completed, check whether readline's word is a subset of the current word, perform completions on the current word as it does now, and then filter out the prefix readline isn't going to use before returning the possible completions.

mmjo avatar Oct 03 '23 17:10 mmjo