Skip to content

Opencode bash tool spawn user commands using /bin/sh what is not bash :-) #3479

Closed

Description

@istarkov

Description

The issue seems like is in the following lines

https://github.com/sst/opencode/blob/dev/packages/opencode/src/tool/bash.ts#L149-L154

Here - shell: true

**shell **- If true, runs command inside of a shell. Uses '/bin/sh' on Unix, and process.env.ComSpec on Windows. A different shell can be specified as a string.

I'm expecting from bash tools to execute at least bash, or default process.env.SHELL but sh feels pretty outdated for me.

Something like this feels more suitable (or check bash existance and use it if it exists in the PATH)

const defaultShell = process.platform === "win32"
  ? true // process.env.ComSpec on Windows
  : process.env.SHELL ?? true // $SHELL - *default shell for new sessions* if set, otherwise /bun/sh

const proc = spawn(params.command, {
  // use the user's login shell (or sensible fallback) rather than the system /bin/sh default
  shell: defaultShell,
  cwd: Instance.directory,
  stdio: ["ignore", "pipe", "pipe"],
  detached: process.platform !== "win32",
})

OpenCode version

0.15.18

Steps to reproduce

In opencode write following prompt


Run following bash command

pid=$$
echo "$(ps -p "$pid" -o comm=)"

The result is

/bin/sh on linux


Screenshot and/or share link

Share links doesn't work for me for unknown reason

Operating System

MacOs

Terminal

ITERM 2

Activity

  1. changed the title [-]Opencode bash tool spawn user commands using `/bin/sh` what is not bash!!!![/-] [+]Opencode bash tool spawn user commands using `/bin/sh` what is not bash :-)[/+] on Oct 27, 2025
  2. github-actions commented on Oct 27, 2025

    @github-actions
    Contributor

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

    Feel free to ignore if none of these address your specific case.

  3. rekram1-node commented on Oct 27, 2025

    @rekram1-node
    Collaborator

    yeah this is good point

  4. SamSpiri commented on Nov 18, 2025

    @SamSpiri

    A tool is called literally "bash". When AI is calling it with bash code it often fails, because it prepares bash code, but it is being executed with sh.

  5. self-assigned this
    on Nov 18, 2025
  6. LankyMoose commented on Oct 6, 2026

    @LankyMoose

    windows user here - still not solved T.T

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions