Skip to content

fix(cli): replace all hyphens in shell completion command names#6213

Open
lihan3238 wants to merge 1 commit intoEffect-TS:mainfrom
lihan3238:fix/cli-completions-hyphen-replace
Open

fix(cli): replace all hyphens in shell completion command names#6213
lihan3238 wants to merge 1 commit intoEffect-TS:mainfrom
lihan3238:fix/cli-completions-hyphen-replace

Conversation

@lihan3238
Copy link
Copy Markdown

Summary

  • Fix command.replace("-", "__") to use command.replaceAll("-", "__") in both bash and zsh completion generators
  • The previous code only replaced the first hyphen in command names, causing multi-hyphenated commands (e.g., type-check-v2) to produce incorrect sanitized names like type__check-v2 instead of type__check__v2

Background

The shell completion generators sanitize command names by replacing hyphens with double underscores (since hyphens are not allowed in bash/zsh function identifiers). However, String.prototype.replace() with a string argument only replaces the first occurrence, so commands with more than one hyphen were only partially sanitized.

Partially addresses #6114

Test plan

  • Verified that both bash and zsh completion generators use the same fix
  • Existing completion snapshot tests should be updated to reflect the fix

The shell completion generators for bash and zsh used
`command.replace("-", "__")` which only replaces the first hyphen
in command names. For commands with multiple hyphens like
`type-check-v2`, this produced `type__check-v2` instead of the
correct `type__check__v2`.

Partially addresses Effect-TS#6114
@lihan3238 lihan3238 requested a review from IMax153 as a code owner May 5, 2026 15:40
@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog May 5, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

⚠️ No Changeset found

Latest commit: 2c229bc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

1 participant