Skip to content

[waiting for #1359] feat(_comp_compgen): support -P prefix with adjusted cur #1360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

akinomyoga
Copy link
Collaborator

See the commit message.

* fix(firefox): do not split longopt argument
* fix(make): work around localvar_inherit
* fix(make): work around custom IFS
* fix(strings): work around nounset
* perf(_comp_delimited): add "$prefix" only when it is non-empty
* refactor(cppcheck): use `_comp_delimited`
* refactor(openssl): prefix "-" to the generated items
@akinomyoga akinomyoga changed the title feat(_comp_compgen): support -P prefix with adjusted cur [waiting for #1359] feat(_comp_compgen): support -P prefix with adjusted cur Apr 6, 2025
The Bash builtin `compgen -P prefix ... -- "$cur"` prepends the prefix
AFTER filtering completions using `$cur`.  However, we usually want to
filter completions with "$cur" starting with the prefix.

To properly handle such a situation, one first needs to check if the
current content of "$cur" is compatible.  Then, one needs to modify
$cur to remove the prefix part, generate completions, and prepends the
prefix to the generated completions.  This pattern is used frequently
in the codebase, so it is good to handle it within `_comp_compgen`.

This patch implements the option `-P` of `_comp_compgen`.  When a
non-empty string is specified to the `-P` option, it performs the
necessary operations: the check and adjustment of $cur, the proper
filtering by the prefix string, and prepending of the prefix string.
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.

1 participant