mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 19:05:11 +00:00
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.
This commit is contained in:
parent
bd276e6931
commit
8fc0610a53
1 changed files with 9 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue