Skip to content

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

Closed as not planned

Description

@FireOrchid2000

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 config — bash 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.

Activity

  1. github-actions commented on Jul 25, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. github-actions commented on Sep 25, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions