diff --git a/src/deps/zig-clap/clap/comptime.zig b/src/deps/zig-clap/clap/comptime.zig index cbd920952b2f7b..7e2046dbb42eb4 100644 --- a/src/deps/zig-clap/clap/comptime.zig +++ b/src/deps/zig-clap/clap/comptime.zig @@ -78,12 +78,7 @@ pub fn ComptimeClap( if (param.names.long == null and param.names.short == null) { try pos.append(arg.value.?); if (opt.stop_after_positional_at > 0 and pos.items.len >= opt.stop_after_positional_at) { - var remaining_ = stream.iter.remain; - const first: []const u8 = if (remaining_.len > 0) bun.span(remaining_[0]) else ""; - if (first.len > 0 and std.mem.eql(u8, first, "--")) { - remaining_ = remaining_[1..]; - } - + const remaining_ = stream.iter.remain; try passthrough_positionals.ensureTotalCapacityPrecise(remaining_.len); for (remaining_) |arg_| { // use bun.span due to the optimization for long strings diff --git a/test/cli/install/bun-run.test.ts b/test/cli/install/bun-run.test.ts index 79379bacdc89d7..56328ccdac93de 100644 --- a/test/cli/install/bun-run.test.ts +++ b/test/cli/install/bun-run.test.ts @@ -485,6 +485,37 @@ it("--ignore-dce-annotations ignores DCE annotations", () => { expect(stdout.toString()).toBe("Hello, world!\n"); }); +it("should preserve '--' in process.argv", async () => { + await mkdir(join(run_dir, "subdir")); + await writeFile( + join(run_dir, "subdir", "test.js"), + ` + console.log(process.argv); + `, + ); + + const { stdout } = spawn({ + cmd: [bunExe(), "run", "subdir/test.js", "--", "rest", "--foo=bar"], + cwd: run_dir, + env: { + ...env, + BUN_INSTALL_CACHE_DIR: join(run_dir, ".cache"), + }, + }); + + const text = await Bun.readableStreamToText(stdout); + + const cleanedText = text.replace(/\n/g, ""); + const argv = JSON.parse(cleanedText); + + // the first argv is bun exe path + // the second argv is the script name + expect(argv[2]).toBe("--"); + expect(argv[3]).toBe("rest"); + expect(argv[4]).toBe("--foo=bar"); + +}); + it("$npm_command is accurate", async () => { await writeFile( join(run_dir, "package.json"),