-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Completion and sudo #2179
Comments
First thing to note is that when shell completion is performed it is the completion script for the sudo command that gets called. And apparently that script knows to call the completion of the relevant command. I’d be curious to know what that completion does to eventually invoke the nerctl completion script. If we’re lucky maybe it can help figure out if the invocation is from sudo. |
This is an assumption. Maybe the shell does something special for sudo. Either way I would suggest looking into the shell completion for sudo as a first step. |
Yeah, I looked into it. On Ubuntu 24.04 at least, this is here: /usr/share/bash-completion/bash_completion (and /usr/share/bash-completion/completions/sudo ) Which is why I was thinking about using |
What I mean is that the following works (as a POC):
|
Hi,
For nerdctl, we are interested in displaying different completion if called with sudo vs. called directly. (containerd/nerdctl#99 ).
Do you have a recommendation on how to implement this / approach this problem?
I assume we would have to patch:
https://github.com/spf13/cobra/blob/v1.8.1/bash_completionsV2.go#L84
to call with sudo if needed.
But then, how do we decide that? Use
_complete_as_root
to test?Thanks a lot.
The text was updated successfully, but these errors were encountered: