Skip to content

feat(tools): run Windows Bash through Git Bash first, matching Claude Code#199

Merged
su-fen merged 1 commit into
mainfrom
features
Jul 21, 2026
Merged

feat(tools): run Windows Bash through Git Bash first, matching Claude Code#199
su-fen merged 1 commit into
mainfrom
features

Conversation

@su-fen

@su-fen su-fen commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

Aligns the built-in Bash tool's Windows shell selection with Claude Code: Git Bash (POSIX semantics) first, with pwsh → Windows PowerShell → cmd kept only as fallbacks when Git Bash is not installed.

Shell resolution (matches Claude Code)

find_git_bash() in shell_runner.rs resolves Git Bash in priority order:

  1. LIVEAGENT_GIT_BASH_PATH env var, then CLAUDE_CODE_GIT_BASH_PATH (trim → unquote → tilde-expand → is_file)
  2. bash.exe on PATH, skipping %SystemRoot%\System32 (that's the WSL launcher, not Git Bash)
  3. Default Git for Windows install paths (ProgramFiles/ProgramW6432/ProgramFiles(x86) + hardcoded roots), preferring Git\bin\bash.exe over Git\usr\bin\bash.exe

The Git Bash candidate runs bash -c (non-login; -lc would source /etc/profile and cd to $HOME, breaking cwd) with no encoding prefix. The PowerShell/cmd fallbacks keep their UTF-8 setup verbatim. ManagedProcess inherits the new chain automatically via spawn_platform_shell_command.

Model guidance flipped to POSIX-first

  • Bash tool description, system prompt (buildToolsSuffix), and failure hints now instruct POSIX/bash syntax on Windows
  • A degraded run (result header shell_family: powershell/cmd) hints to install Git for Windows or set LIVEAGENT_GIT_BASH_PATH
  • POSIX & background-detach validation now applies on Windows too (Bash + ManagedProcess); the old runtimePlatform !== "windows" gates are removed
  • Cancelled-result synthesized metadata updated to windows-git-bash/posix

Untouched

Interactive terminal (terminal/shell.rs), MCP launcher cmd.exe, web frontend (no shellTools mirror).

Testing

  • pnpm test (agent-gui): 1103 pass / 0 fail
  • cargo test shell_runner: 10 pass
  • cargo fmt --check / Biome clean
  • ⚠️ Two new #[cfg(windows)] tests (chain order, env-override precedence) need Windows CI/machine to actually run; the cfg(windows) code was compile-verified separately (cross-target cargo check on macOS dies in aws-lc-sys's C build script, unrelated to this change)

… Code

Replace the Windows shell chain pwsh -> powershell -> cmd with Git Bash
(POSIX semantics) first, keeping pwsh/powershell/cmd as fallbacks only
when Git Bash is missing.

- find_git_bash resolves via LIVEAGENT_GIT_BASH_PATH, then
  CLAUDE_CODE_GIT_BASH_PATH, then bash.exe on PATH (skipping the WSL
  launcher in System32), then default Git for Windows install paths
- Git Bash candidate runs bash -c without encoding prefixes; the
  PowerShell/cmd fallbacks keep their UTF-8 setup verbatim
- ManagedProcess inherits the new chain via spawn_platform_shell_command
- Tool description, system prompt, and failure hints flip to
  POSIX-first guidance; a degraded run (shell_family powershell/cmd)
  now hints to install Git for Windows or set LIVEAGENT_GIT_BASH_PATH
- POSIX ampersand background validation now applies on Windows too
- Tests: chain-order and env-override cfg(windows) tests, flipped
  Windows cases in shell-tools/markdown-image-policy suites
@su-fen
su-fen merged commit 9e8ba6b into main Jul 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant