Windows: bash tool shell is compiled in (cmd.exe /D /S /C); make it configurable so Git Bash can be used
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19.9k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 30
Description
Summary
On Windows, the built-in bash tool always spawns cmd.exe /D /S /C "<command>", and the shell is selected at compile time. There is no config key and no environment variable to route commands through Git Bash (or any other shell), so anyone whose project tooling is POSIX-based has to hand-roll a wrapper on every call.
Related, but not the same: #1254 (a dedicated PowerShell tool next to the cmd.exe branch) and #630 (configurable shell for ! commands). This issue is specifically about making the existing bash tool's shell selectable.
Environment
- Windows 11 x64
- jcode v0.84.0 (57d587899), prebuilt release binary
Evidence that the shell is compiled in
Scanning the release binary for the shell entry point:
- the only shell-spawning strings are
cmd.exe+/D+/S+/C, emitted fromcrates/jcode-app-core/src/tool/(see theBashInputdescription string: "Run a Windows cmd.exe command (compatibility namebash). Use cmd.exe syntax, not Bash."). COMSPEChas 0 occurrences, so the standard Windows mechanism for overriding the command interpreter is not consulted.- a hypothetical
JCODE_SHELL/shell_path/default_shellconfig key has 0 occurrences, andjcode --helpexposes no shell option.
Impact
- Every POSIX command has to be manually wrapped, e.g.
"C:\Program Files\Git\bin\bash.exe" -lc "<command>", in every tool call, and it must be re-discovered by each new session. - Quoting is fragile because the outer
cmd.exeboth expands%VAR%and parses the whole line before bash sees it:%PATH%is expanded by cmd.exe, so only bash's${PATH}form is safe.;and,are token separators to cmd.exe, so a bash command that relies on;inside cmd-visible quoting can be split into multiple arguments (observed:bash -lc 'echo a; ls'mangled totr: extra operand).- a command whose final character is a quote can desynchronise cmd.exe's quote pairing.
- Output/exit-code behaviour is otherwise fine, so this is purely a shell-selection gap.
Suggested fix
Any one of:
- a config knob, e.g.
[tools] shell_path = "C:\\Program Files\\Git\\bin\\bash.exe"orshell = "cmd" | "pwsh" | "git-bash", applied as<shell> <args> -c "<command>"; - a
JCODE_SHELLenv override; - auto-detect and prefer Git Bash when
bash.exeis present, falling back tocmd.exe(this also removes the POSIX-quoting hazard for those users).
A related nicety: when a POSIX shell is selected, the tool description shown to the model should switch from "cmd.exe syntax" to bash semantics, since that text currently misleads the agent.
Workaround currently in use
A one-line forwarder on PATH (jb.cmd):
@echo off
setlocal enableextensions
set "GITBASH=C:\Program Files\Git\bin\bash.exe"
if not exist "%GITBASH%" set "GITBASH=C:\Program Files\Git\usr\bin\bash.exe"
"%GITBASH%" --login -c %*
exit /b %ERRORLEVEL%
Called as jb "<bash command>", this preserves the working directory and propagates exit codes (verified for 0/1/7/127), but it only fixes the shell, not the underlying cmd.exe quoting layer, and it must be recreated on every machine.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in crates/jcode-app-core/src/tool/ and locate the existing BashInput implementation and its Windows cmd.exe spawning path. Read nearby configuration and environment-override patterns before choosing how shell selection should be represented. Done means the existing bash tool can select a configured shell without the cmd.exe quoting layer, and its displayed syntax description matches the selected shell.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100