Skip to content
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

Fix colon in bash completion #1984

Merged

Conversation

jrohel
Copy link
Contributor

@jrohel jrohel commented Jan 3, 2025

Closes: #1982

Word completion may behave improperly if there is a colon in the word to be completed. The colon can be special to readline's word completion code: it can be one of the characters that breaks words for the completer.

The current set of completion word break characters is available in bash as the value of the COMP_WORDBREAKS variable. Removing : from that value is enough to make the colon not special to completion: COMP_WORDBREAKS=${COMP_WORDBREAKS//:}

This fix is workaround for cases where : is a break character (it is contained in COMP_WORDBREAKS). A side effect in this case is the removal of the prefix containing the colon in the list of bash completion suggestions.

jrohel added 2 commits January 3, 2025 17:42
To make sure there is no collision with global variables in other
scripts, the global variable "dnf_target" was removed and
"complete_cmds" was renamed to "_complete_dnf5_cmds".
Word completion may behave improperly if there is a colon in the word
to be completed. The colon can be special to readline's word completion
code: it can be one of the characters that breaks words for
the completer.

The current set of completion word break characters is available in bash
as the value of the COMP_WORDBREAKS variable.  Removing ':' from that
value is enough to make the colon not special to completion:
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}

This fix is workaround for cases where ':' is a break character (it is
contained in COMP_WORDBREAKS). A side effect in this case is the removal
of the prefix containing the colon in the list of bash completion
suggestions.
Copy link
Member

@evan-goode evan-goode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, I ran into this while testing #1983 but assumed it was a bug in my Bash configuration. I think this is a reasonable workaround. LGTM.

@evan-goode evan-goode added this pull request to the merge queue Jan 8, 2025
Merged via the queue into rpm-software-management:main with commit f6b851a Jan 8, 2025
17 checks passed
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.

Bash completion behaves incorrectly if there is a colon ':' in the word
2 participants