anomalyco / anomalyco/opencode

[FEATURE]:Make `bash` tool respect `shell` config or add env var override

Open
#38,799 1 comment 2 reactions 1 assignee View on GitHub

@Hona is already working on this.

Since Jul 25, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Feature hasn't been suggested before.
  • I have verified this feature I'm about to request hasn't been suggested before.

Summary

The built-in bash tool on Windows is hardcoded to use cmd.exe /c, ignoring the shell field in opencode.json (e.g., "shell": "pwsh"). Please make the tool configurable.

Current Behavior

  • opencode.json has "shell": "pwsh"
  • But the AI's bash tool always uses cmd.exe /c on Windows
  • Config value is only used for TUI terminal, MCP server spawn, shell completions, etc. — not for the bash tool

Expected Behavior

One of:

  1. Read shell configbash tool uses the configured shell (pwsh, bash, nu, etc.)
  2. Add env var override — e.g., OPENCODE_BASH_SHELL=pwsh or OPENCODE_SHELL=pwsh
  3. Add CLI flag--shell=pwsh that affects the tool

Rationale

  • PowerShell 7+ (pwsh) is widely available on Windows and is the modern default
  • Users explicitly configure shell: "pwsh" expecting it to apply everywhere
  • Current workaround requires every command to be wrapped: pwsh -c "..." — verbose and error-prone
  • Cross-platform consistency: on Unix the tool uses sh -c (respects $SHELL indirectly), Windows should respect config too

Workaround Today

# Every single command must be wrapped
pwsh -c "Get-ChildItem"
pwsh -c "git status"

Suggested Implementation

// packages/opencode/src/tool/bash.ts
const shell = config.shell ?? process.env.OPENCODE_BASH_SHELL ?? (isWindows ? "cmd.exe" : "sh");
const args = isWindows ? ["/c"] : ["-c"];

Environment

  • opencode version: latest
  • OS: Windows 10/11
  • Shell: PowerShell 7.6.3 (pwsh)

Related: The shell config already exists and works for other subsystems — just not the bash tool. This feels like an oversight.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.