Expand description
Locate the POSIX sh that shellexec (the !cmd composer prefix) runs
its one-shot sh -c commands under.
On Unix this is just sh. On Windows it was also just sh, which only
resolves when srv’s PATH happens to contain a Git Bash tool directory —
true for a dev build started from a Git Bash terminal, false for an
installed/portable build started from Explorer. Git for Windows’ installer
puts only Git\cmd on the system PATH by default, and that directory has
git.exe but no sh.exe, so every !cmd failed with
shellexec: spawn failed: program not found.
Two traps shape the Windows search order:
Git\usr\bin\sh.exe(the real binary) cannot runlsunless its own directory is already on PATH.Git\bin\sh.exeis Git’s launcher: it prepends/mingw64/bin:/usr/binitself, so the fallbacks below point atbin\sh.exe, neverusr\bin\sh.exe.C:\Windows\System32\bash.exeis WSL. A PATH search forbashwould run!cmdinside a Linux VM with different paths, so the PATH search looks forsh.exeonly (WSL ships nosh.exe).
Constants§
- SHELL_
OVERRIDE_ ENV - Explicit override: a path to a bash/sh executable. Same variable agentmux-bashwrap honours for its own bash lookup.
Functions§
- git_
launcher 🔒 - Git for Windows’
shlauncher under an install root. - is_
windows_ 🔒absolute C:\…/\\server\…. Checked by hand rather thanPath::is_absoluteso the rule is the same when the tests run on a Unix CI host. A bare\foois drive-relative on Windows, so it doesn’t count.- resolve_
posix_ shell - Resolve the program
shellexecshould spawn as<program> -c <cmd>. - resolve_
windows 🔒 - Windows search order, first hit wins: