Skip to content

Fix zsh dashes in command names #284

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

Merged
merged 1 commit into from
Mar 6, 2021

Conversation

adellibovi
Copy link
Contributor

Hi, this PR fixes #277

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

Copy link
Member

@natecook1000 natecook1000 left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this, @adellibovi! 👏 A couple notes below.

Comment on lines 18 to 19
#compdef \(type._commandName)
#compdef \(commandName)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this part can change — IIUC the #compdef tells Zsh what command the completions are for, so they need to match the executable.

local context state state_descr line
_\(type._commandName)_commandname=$words[1]
_\(commandName)_commandname=$words[1]
Copy link
Member

Choose a reason for hiding this comment

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

As far as I understand it, this is the only part that needs to change, since dashes are allowed in the function names, just not as a variable name. Can you still reproduce the issue if you only change this part here? As an extra benefit, this smaller change wouldn't cause problems for people who declare both sub-command and sub_command subcommands (which is a bad idea, but it will surely happen eventually).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, this is the only required changes. I made the change and tried locally :) Thanks for catching it @natecook1000. PR updated!

@adellibovi adellibovi force-pushed the fix-zsh-dash-command-name branch from f47a00f to 2239419 Compare March 6, 2021 17:41
@adellibovi adellibovi requested a review from natecook1000 March 6, 2021 17:42
@natecook1000
Copy link
Member

@swift-ci Please test

Copy link
Member

@natecook1000 natecook1000 left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

Dashes in command names break completion scripts
2 participants