Skip to content

cli: handle -v/--version in the node argv0 shim - #36128

Open
robobun wants to merge 4 commits into
mainfrom
farm/6fde7ab4/node-shim-version
Open

cli: handle -v/--version in the node argv0 shim#36128
robobun wants to merge 4 commits into
mainfrom
farm/6fde7ab4/node-shim-version

cli: handle -v/--version in the node argv0 shim

102a266
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 27, 2026 in 13m 50s

Code review found 2 potential issues

Found 2 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 2
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/runtime/cli/mod.rs:1532-1539 Scan breaks on the value of a preceding option; node -r ./x --version still fails
🟡 Nit src/runtime/cli/mod.rs:1532-1539 Lone '-' (stdin sentinel) not treated as positional; node - --version is intercepted

Annotations

Check warning on line 1539 in src/runtime/cli/mod.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Scan breaks on the value of a preceding option; node -r ./x --version still fails

The scan breaks on the first non-dash arg, but for value-taking flags in `RUN_TABLE` (`-r/--require`, `--import`, `--title`, `--conditions`, ...) that arg is the flag's *value* — so `node -r ./preload.js --version` breaks on `./preload.js`, never sees `--version`, and still exits 1 with "Missing script". This also bites bare `node -v` when `BUN_OPTIONS='-r ./x'` is set, since those tokens are spliced into argv after argv[0]. Not a regression (same behavior before this PR), so non-blocking — but 

Check warning on line 1539 in src/runtime/cli/mod.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Lone '-' (stdin sentinel) not treated as positional; node - --version is intercepted

The lone `-` (stdin sentinel) is not treated as a positional here — `a.first() != Some(&b'-')` is false for `b"-"`, so the loop continues past it and `node - --version` now prints the Node version instead of erroring/passing `--version` to the stdin script. Bun's own clap classifier already special-cases `b"-"` as `ArgKind::Positional` (streaming.rs:306), and real Node passes the flag through; add a `b"-" => break` arm alongside `b"--"`.