Skip to main content

Module windows_shell

Module windows_shell 

Source
Expand description

Shared Windows shell selection for foreground and background bash commands.

Mirrors OpenCode’s resolver:

  1. $SHELL env var (typically points at git-bash on Windows dev setups).
  2. pwsh.exe (PowerShell 7+).
  3. powershell.exe (Windows PowerShell 5.1).
  4. Git-for-Windows bash.exe discovered next to git on PATH (catches users who installed Git for Windows but never set $SHELL).
  5. cmd.exe (universal floor — always reachable on every Windows SKU).

POSIX shells (bash, sh, zsh, ksh, dash) are invoked as <shell> -c <cmd> the same way Unix does. PowerShell variants take their -Command shape; cmd.exe takes /D /C.

Compiled on all platforms so the cross-platform retry-decision unit tests in commands::bash::try_spawn_with_fallback (test-only — see the Windows foreground bash path in crate::commands::bash) can run on macOS/Linux dev machines. The production Windows background spawn path at bash_background::registry::detached_shell_command_for is the live caller.