Skip to content

Conversation

@JeffFaer
Copy link
Contributor

On the first tab (COMP_TYPE=9), Bash will automatically insert the common prefix of the matching completion options. We need to make sure those completion options are escaped since some part of them might end up on the command line.

On subsequent tabs (COMP_TYPE=63), Bash will display the completion options to the user, so we don't want to escape them for that COMP_TYPE.

@marckhouzam
Copy link
Collaborator

Thanks. Can you provide a clear example of when this is needed?

@JeffFaer
Copy link
Contributor Author

Let's say the completion options for some command are

foo>bar
foo>baz
quux

The user would probably want behavior like the following

$ cmd <TAB>
<nothing>
$ cmd <TAB><TAB>
foo>bar
foo>baz
quux
$ cmd f<TAB>
$ cmd foo\><TAB><TAB>
foo>bar
foo>baz

That $ cmd f<TAB> completion request is COMP_TYPE=9. If we don't escape the completion options on that comp type, Bash would insert an unescaped foo> as the common prefix. The <TAB><TAB> completion requests are COMP_TYPE=63, and we don't want to escape for those.

Otherwise, we end up putting a single empty string in COMPREPLY.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants