From 8fc0610a53f9914ccc2e2f951166afeb41ae208a Mon Sep 17 00:00:00 2001 From: Daniel Nouri Date: Fri, 26 Dec 2025 23:06:03 +0100 Subject: [PATCH] fix: Use bash instead of sh on Unix systems The bash tool is named "bash" and described as executing bash commands, but was using sh on Unix. On many distros (Ubuntu, Debian, Alpine, etc.), /bin/sh is a POSIX-only shell that doesn't support bash syntax like [[ ]], arrays, or here-strings. This caused the LLM to write bash syntax that failed, wasting tokens on rewrites. Now prefers /bin/bash on Unix, falling back to sh only if bash isn't found. --- packages/coding-agent/src/utils/shell.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/coding-agent/src/utils/shell.ts b/packages/coding-agent/src/utils/shell.ts index d2a1f74f..b9e45f64 100644 --- a/packages/coding-agent/src/utils/shell.ts +++ b/packages/coding-agent/src/utils/shell.ts @@ -26,8 +26,9 @@ function findBashOnPath(): string | null { * Get shell configuration based on platform. * Resolution order: * 1. User-specified shellPath in settings.json - * 2. On Windows: Git Bash in known locations - * 3. Fallback: bash on PATH (Windows) or sh (Unix) + * 2. On Windows: Git Bash in known locations, then bash on PATH + * 3. On Unix: /bin/bash + * 4. Fallback: sh */ export function getShellConfig(): { shell: string; args: string[] } { if (cachedShellConfig) { @@ -83,6 +84,12 @@ export function getShellConfig(): { shell: string; args: string[] } { ); } + // Unix: prefer bash over sh + if (existsSync("/bin/bash")) { + cachedShellConfig = { shell: "/bin/bash", args: ["-c"] }; + return cachedShellConfig; + } + cachedShellConfig = { shell: "sh", args: ["-c"] }; return cachedShellConfig; }