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

Use cmd.Name when generating completion script #2012

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

bartekpacia
Copy link
Member

@bartekpacia bartekpacia commented Nov 24, 2024

This PR fixes a bug in completion scripts when the binary is called in any other way than by simply typing its name. Examples:

  • When installing my program emu with Homebrew, os.Args[0] is /opt/homebrew/Cellar/emu/0.2.16/bin/emu.

  • When running my program emu like this: ./emu, then os.Args[0] is ./emu.

This breaks the completion script.
I think using root command's cmd.Name is a good way to fix it.

Also discussed here

@bartekpacia bartekpacia requested a review from a team as a code owner November 24, 2024 21:38
@bartekpacia bartekpacia merged commit 6d4e81c into main Nov 25, 2024
15 checks passed
@bartekpacia bartekpacia deleted the bartekpacia/fix/completion_script_executable_name branch November 25, 2024 13:30
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.

2 participants