What shell is used on Windows power shell when doing a bash toolcall?
Question
To me as a user it seems it sometimes uses WSL2 to execute a bash command and sometimes it uses the power shell instance that I start opencode with. I know it's recommended to run opencode in a bash capable environment but for now it's more convenient for me to use powershell.
So what determines what shell is called? I instruct my agent to use power shell commands but sometimes it ends up in WSL2 and vice versa. So what is happening under the hood and how can I make sure the agent will always use one shell and not the other? The tool call is called bash which is confusing for the agent as well. If the tool would be called shell, it can be power shell as well as bash.
This issue might be a duplicate of existing issues. Please check:
- #5476: Bad experience installing OpenCode for Windows - discusses WSL vs PowerShell shell selection issues on Windows
- #4683: [FEATURE]: allow multiple shell setups and allow switching them at runtime via TUI command - directly addresses shell switching on Windows and distinguishes between PowerShell, cmd.exe, and bash
Both issues discuss similar shell selection behavior on Windows where the wrong shell environment is used. Feel free to ignore if your specific case differs from these.
This file kinda covers how it works, and believe me i know it's POOR: https://github.com/sst/opencode/blob/c3b3b133b0b405a4cad700e57194620f653ee215/packages/opencode/src/shell/shell.ts#L39
We are going to add a powershell tool that will be provided to agent instead of bash tool if your shell is powershell.
We use git bash rn as a bandaid if we can find it