From 3a6ed5d5464332bd03fc7fbeb77ed2295ef690b3 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Tue, 17 Mar 2026 21:35:19 -0700 Subject: [PATCH] Handle -c flag position for both shebang and compiled argv layouts When run via shebang, bun prepends itself so -c appears at argv[2] instead of argv[1]. Search both positions to support either mode. --- src/cli/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index a1e030d..f8a3f61 100755 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -6,7 +6,9 @@ const noArgs = process.argv.length <= 2 const isTTY = !!process.stdin.isTTY // SSH login shell passes commands as: toes -c "command args" -const shellExec = process.argv[1] === '-c' ? process.argv.slice(2).join(' ') : null +// With shebang, argv is [bun, script, -c, cmd]; compiled, it's [toes, -c, cmd] +const cIndex = process.argv[1] === '-c' ? 1 : process.argv[2] === '-c' ? 2 : -1 +const shellExec = cIndex !== -1 ? process.argv.slice(cIndex + 1).join(' ') : null if (shellExec) { const tokens = shellExec.split(/\s+/).filter(Boolean)