Skip to content

fix(cli): honor shell argument in completion command - #41235

Open
Cyame wants to merge 1 commit into
anomalyco:devfrom
Cyame:fix/completion-shell-positional
Open

fix(cli): honor shell argument in completion command#41235
Cyame wants to merge 1 commit into
anomalyco:devfrom
Cyame:fix/completion-shell-positional

Conversation

@Cyame

@Cyame Cyame commented Aug 8, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #41232

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

opencode completion fish currently prints a bash or zsh script depending on $SHELL. yargs (pinned at 18.0.0) picks the completion template from the environment and ignores the positional argument, so sourcing the output in fish fails with "Unsupported use of '='" at the first oc prompt.

An upstream yargs bump does not fix this: no released yargs has fish support yet, and the unreleased one still keys off $SHELL only. Details are in #41232.

This replaces yargs' .completion() with a completion [shell] command that:

  • honors the positional argument for bash, zsh and fish
  • falls back to $SHELL when the argument is omitted
  • falls back to bash for unknown values, keeping the previous behavior

The fish template is the one from yargs/yargs#2568 (MIT). --get-yargs-completions is yargs core and is not touched.

How did you verify your code works?

  • With SHELL=/bin/zsh, opencode completion fish prints a fish script. Before this change it printed a zsh script.
  • completion bash and completion zsh output is unchanged.
  • completion tcsh falls back to bash like the old code did.
  • opencode --get-yargs-completions c still lists subcommands.
  • New tests in test/cli/cmd/completion.test.ts: 8 passing.
  • tsgo --noEmit passes.

Screenshots / recordings

No UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 8, 2026
@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

opencode completion fish emits bash/zsh script, not fish syntax

1 participant