anomalyco / anomalyco/opencode
[FEATURE]:Make `bash` tool respect `shell` config or add env var override
Open
@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.jsonhas"shell": "pwsh"- But the AI's
bashtool always usescmd.exe /con Windows - Config value is only used for TUI terminal, MCP server spawn, shell completions, etc. — not for the
bashtool
Expected Behavior
One of:
- Read
shellconfig —bashtool uses the configured shell (pwsh, bash, nu, etc.) - Add env var override — e.g.,
OPENCODE_BASH_SHELL=pwshorOPENCODE_SHELL=pwsh - Add CLI flag —
--shell=pwshthat 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$SHELLindirectly), 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.