MCPcopy Index your code
hub / github.com/TanStack/ai / posixShell

Function posixShell

packages/ai-sandbox-local-process/src/handle.ts:44–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42 */
43let cachedShell: string | undefined
44function posixShell(): string {
45 if (cachedShell !== undefined) return cachedShell
46 if (process.platform !== 'win32') return (cachedShell = 'sh')
47
48 const candidates: Array<string> = []
49 if (process.env.TANSTACK_SANDBOX_SH) {
50 candidates.push(process.env.TANSTACK_SANDBOX_SH)
51 }
52 for (const dir of (process.env.PATH ?? '').split(path.delimiter)) {
53 if (/\\git\\cmd\\?$/i.test(dir)) {
54 candidates.push(path.join(dir, '..', 'usr', 'bin', 'sh.exe'))
55 candidates.push(path.join(dir, '..', 'bin', 'sh.exe'))
56 }
57 }
58 candidates.push(
59 'C:\\Program Files\\Git\\usr\\bin\\sh.exe',
60 'C:\\Program Files\\Git\\bin\\sh.exe',
61 )
62 for (const candidate of candidates) {
63 if (candidate && existsSync(candidate)) return (cachedShell = candidate)
64 }
65 // Last resort: rely on PATH (a clear ENOENT if no POSIX sh is installed).
66 return (cachedShell = 'sh')
67}
68
69/**
70 * Extra PATH dirs so a Windows git-bash `sh` can find its Unix tools (`sed`,

Callers 3

posixShellPathDirsFunction · 0.85
execMethod · 0.85
spawnProcessMethod · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected