Closed yedayak closed 3 months ago
I moved to using _comp_quote_compgen
which seems more appropriate. This also allowed me to remove the %q printf
Thank you for updating!
I moved to using
_comp_quote_compgen
which seems more appropriate.
Do you have an explanation for it? I feel _comp_quote_compgen
is not the one because it is intended for cur
(i.e., the string used to filter the generated completions) but not for the generated completions. It does some extra modifications that seem inappropriate to apply to the generated completions.
Thank you for updating!
I moved to using
_comp_quote_compgen
which seems more appropriate.Do you have an explanation for it? I feel
_comp_quote_compgen
is not the one because it is intended forcur
(i.e., the string used to filter the generated completions) but not for the generated completions. It does some extra modifications that seem inappropriate to apply to the generated completions.
From what I tested it seems _comp_quote
adds single quotes unconditionally, while _comp_quote_compgen
quotes spaces and such with backslashes. Also, using _comp_quote
just doesn't seem to actually complete, it completes '
but that's it (this is with _comp_quote
):
$ ip netns list
blah bah
rgergerg
$ ip netns delete # Completes '
$ ip netns delete '<TAB>
'blah bah' 'rgergerg'
$ ip netns delete 'b<TAB> # Completes nothing
From what I tested it seems
_comp_quote
adds single quotes unconditionally, while_comp_quote_compgen
quotes spaces and such with backslashes. Also, using_comp_quote
just doesn't seem to actually complete, it completes'
but that's it (this is with_comp_quote
):
What I suggested in https://github.com/scop/bash-completion/pull/1140#discussion_r1535012572 is to use printf %q
(but not _comp_quote
). Do you have an explanation for the reason that _comp_quote_compgen
is preferred over printf %q
? In particular, this part and this part are the differences from printf %q
, but how are they used in the present case?
From what I tested it seems
_comp_quote
adds single quotes unconditionally, while_comp_quote_compgen
quotes spaces and such with backslashes. Also, using_comp_quote
just doesn't seem to actually complete, it completes'
but that's it (this is with_comp_quote
):What I suggested in #1140 (comment) is to use
printf %q
(but not_comp_quote
). Do you have an explanation for the reason that_comp_quote_compgen
is preferred overprintf %q
? In particular, this part and this part are the differences fromprintf %q
, but how are they used in the present case?
OK, I didn't get that. Just using printf %q
seems to work fine, pushed a version with that
Network namespaces can have spaces in them, which lead to incorrect completions in that case. Fix it by calling _comp_quote on all namespace names.
There are probably better ways to do this than overwriting
$COMPREPLY
, but I couldn't find one.