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.
This commit is contained in:
parent
3328009af6
commit
3a6ed5d546
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user