bash-completion: fix setsid sub-command completion#4398
Open
lzwind wants to merge 1 commit into
Open
Conversation
cgoesche
suggested changes
Jun 3, 2026
| COMPREPLY=( $(compgen -c -- $cur) ) | ||
|
|
||
| if [[ "$cur" == -* ]]; then | ||
| COMPREPLY=( $(compgen -W "${NOARGOPTS// /|}" -- $cur) ) |
Collaborator
There was a problem hiding this comment.
The parameter expansion is actually not needed here, it will otherwise turn the original $NOARGOPT string into a new string --ctty|--wait|--fork|--help|--version, which will make the comp spec always complete the option to that new string.
Suggested change
| COMPREPLY=( $(compgen -W "${NOARGOPTS// /|}" -- $cur) ) | |
| COMPREPLY=( $(compgen -W "$NOARGOPTS" -- $cur) ) |
Contributor
Author
|
Thanks @cgoesche for the catch! I've fixed the parameter expansion issue - replaced The fix has been pushed to the branch. |
The setsid completion used the old manual COMP_WORDS/COMP_CWORD pattern and never delegated to the sub-command's own completion. When typing e.g. "setsid -f rm -<Tab>", completion would show setsid options instead of rm options. Rewrite to use _init_completion and _command_offset, matching the pattern used by unshare and other wrapper commands. This correctly detects where the sub-command begins and delegates completion to it. Fixes: util-linux#4073 Co-developed-by: Claude Sonnet 4.6 <noreply@anthropic.com>
abb819a to
0507236
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
COMP_WORDS/COMP_CWORDpattern and never delegated to the sub-command's own completionsetsid -f rm -<Tab>, completion showed setsid options instead of rm options_init_completionand_command_offset, matching the pattern used byunshareand other wrapper commandsPartially fixes: #4073
Test plan
setsid -f rm -<Tab>should complete with rm optionssetsid --fork --wait ls -<Tab>should complete with ls optionssetsid -<Tab>should still show setsid optionsCo-developed-by: Claude Sonnet 4.6 noreply@anthropic.com