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

windows completions not working with shopt -s completion_strip_exe #16499

Closed
patricklx opened this issue Nov 14, 2022 · 16 comments
Closed

windows completions not working with shopt -s completion_strip_exe #16499

patricklx opened this issue Nov 14, 2022 · 16 comments
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue

Comments

@patricklx
Copy link

its possible to remove the .exe extension to use binaries in windows git bash by specifying shopt -s completion_strip_exe
but podman is not considering that for the completions.

it registers only podman.exe: complete -o default -F __start_podman.exe podman.exe
it should also inlclude without .exe extension: complete -o default -F __start_podman.exe podman.exe podman.

@Luap99
Copy link
Member

Luap99 commented Nov 14, 2022

Please fill out the issue template as requested.

Podman does not create the completion scripts, they are generated by the https://github.com/spf13/cobra library. The library simply generates the name based of the program name (podman sets it to argv[0]). I don't think it should know about .exe or any other special extensions.
If you run podman completion bash it should output the completion script line with just podman as name, that assumes argv[0] is podman and not converted to podman.exe by git bash before it calls the process.

@patricklx
Copy link
Author

ah, right its in cobra, I found it in this repo, https://github.com/containers/podman/blob/main/vendor/github.com/spf13/cobra/bash_completionsV2.go#L356 but did not see it was under vendor.
yes, it looks like bash does convert it to podman.exe when calling the process

@Luap99
Copy link
Member

Luap99 commented Nov 14, 2022

Did you check how it works in powershell?

@patricklx
Copy link
Author

just tried it now, does not work either, because its just using podman.exe in the variable names, which then turns into a property lookup... so I get this error The property 'exeCompleterBlock' cannot be found on this object.
Register-ArgumentCompleter -CommandName 'podman.exe' -ScriptBlock $__podman.exeCompleterBlock

@Luap99
Copy link
Member

Luap99 commented Nov 14, 2022

I think you need to run both podman.exe completion powershell | Out-String | Invoke-Expression and podman completion powershell | Out-String | Invoke-Expression in powershell, at least this is how I remember it when I was working on it.

@patricklx
Copy link
Author

tried both, same issue

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Dec 17, 2022

@n1hility @Luap99 any movement on this one?

@Luap99
Copy link
Member

Luap99 commented Dec 17, 2022

I think this must be fixed upstream, spf13/cobra#1853

@n1hility
Copy link
Member

Note that this is the same issue as #15527. @cdoern was planning to look into the cobra issue not sure if he did yet? @cdoern ?

@cdoern
Copy link
Contributor

cdoern commented Dec 18, 2022

I will work on both this week @n1hility I just got home from finals :)

cdoern added a commit to cdoern/podman that referenced this issue Dec 18, 2022
resolves containers#15527, containers#16499

Signed-off-by: Charlie Doern <cbddoern@gmail.com>
@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Jan 19, 2023

@cdoern @n1hility any chance to work on this?

@Luap99
Copy link
Member

Luap99 commented Jan 19, 2023

As best as I can see this is something that cobra upstrem must fix. The shell completion scripts are auto generated by this library.

@rhatdan
Copy link
Member

rhatdan commented Jan 19, 2023

Ok I think we can close this issue as we wait for this to be fixed in cobra, once it is fixed there podman will get the fix on a vendor.

@KongrooParadox
Copy link

In the meantime there is this hacky solution to fix completion : (podman completion powershell | Out-String) -replace "podman.exe", "podman" | Invoke-Expression

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 3, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue
Projects
None yet
Development

No branches or pull requests

6 participants