From f8c93cac26c3290769f978e5ddb70696373dcd4e Mon Sep 17 00:00:00 2001 From: Sorra Date: Wed, 11 Mar 2026 02:09:05 -0700 Subject: [PATCH] WL-0MM37JWXN0N0YYCF: Run gh CLI invocations under bash to avoid sh/dash syntax errors --- src/github.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/github.ts b/src/github.ts index de55c7a..b1188ba 100644 --- a/src/github.ts +++ b/src/github.ts @@ -42,7 +42,7 @@ function runGh(command: string, input?: string): string { const outFd = fs.openSync(outPath, 'w'); const errFd = fs.openSync(errPath, 'w'); try { - const res = spawnSync('/bin/sh', ['-c', command], { + const res = spawnSync('/bin/bash', ['-c', command], { encoding: 'utf-8', stdio: ['pipe', outFd, errFd], input, @@ -75,6 +75,7 @@ function runGh(command: string, input?: string): string { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'], input, + shell: '/bin/bash', }).toString().trim(); } catch (err: any) { const stderr = (err?.stderr ? String(err.stderr) : '') || err?.message || ''; @@ -113,7 +114,7 @@ function runGhDetailed(command: string, input?: string): { ok: boolean; stdout: const outFd = fs.openSync(outPath, 'w'); const errFd = fs.openSync(errPath, 'w'); try { - const res = spawnSync('/bin/sh', ['-c', command], { + const res = spawnSync('/bin/bash', ['-c', command], { encoding: 'utf-8', stdio: ['pipe', outFd, errFd], input, @@ -153,7 +154,7 @@ function runGhDetailed(command: string, input?: string): { ok: boolean; stdout: // Async variants ----------------------------------------------------------- function spawnCommand(command: string, input?: string, timeout = 120000): Promise<{ stdout: string; stderr: string; code: number | null; error?: Error }> { return new Promise((resolve) => { - const child = spawn('/bin/sh', ['-c', command], { stdio: ['pipe', 'pipe', 'pipe'] }); + const child = spawn('/bin/bash', ['-c', command], { stdio: ['pipe', 'pipe', 'pipe'] }); let stdout = ''; let stderr = ''; const timer = setTimeout(() => {