[PR #3712] [WIP] fix: respect SHELL environment variable on Windows for bash commands #10736

Closed
opened 2026-02-16 18:15:28 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3712

State: closed
Merged: No


On Windows, when SHELL env was set (e.g., to Git Bash), LLM-executed bash commands and user shell commands would ignore it and use cmd.exe instead.

Changes:

  • Strip Windows executable extensions (.exe/.cmd/.bat) from shell name
    detection so bash.exe is correctly matched to bash invocation rules
  • Explicitly pass SHELL env to spawn() on Windows instead of relying on
    shell: true which defaults to cmd.exe
  • This restores support for Git Bash and other POSIX shells on Windows

Tested with nushell and bash.exe from Git For Windows

Required for user that using Git Bash:

  • Set SHELL env to C:\Program Files\Git\usr\bin\bash.exe
  • C:\Program Files\Git\usr\bin need to be in path so the bash can use others linux utilities command.

Here is the video of using with Git Bash

https://github.com/user-attachments/assets/bb843848-43fe-4d08-afba-10a12835aad6

Here is the video of using with Nushell

https://github.com/user-attachments/assets/f78a20e2-c8e2-472a-9998-135629cb5cd8

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3712 **State:** closed **Merged:** No --- On Windows, when SHELL env was set (e.g., to Git Bash), LLM-executed bash commands and user shell commands would ignore it and use cmd.exe instead. Changes: - Strip Windows executable extensions (.exe/.cmd/.bat) from shell name detection so bash.exe is correctly matched to bash invocation rules - Explicitly pass SHELL env to spawn() on Windows instead of relying on shell: true which defaults to cmd.exe - This restores support for Git Bash and other POSIX shells on Windows **Tested with nushell and bash.exe from Git For Windows** **Required for user that using Git Bash:** - Set SHELL env to `C:\Program Files\Git\usr\bin\bash.exe` - `C:\Program Files\Git\usr\bin` need to be in path so the bash can use others linux utilities command. Here is the video of using with Git Bash https://github.com/user-attachments/assets/bb843848-43fe-4d08-afba-10a12835aad6 Here is the video of using with Nushell https://github.com/user-attachments/assets/f78a20e2-c8e2-472a-9998-135629cb5cd8
yindo added the pull-request label 2026-02-16 18:15:28 -05:00
yindo closed this issue 2026-02-16 18:15:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10736