From c3a2b51a2cdd5a64401df2ad326c20f151455f00 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sat, 5 Mar 2022 15:23:08 -0700 Subject: [PATCH] fix regression in `zig run` runtime arguments This brings back #10950, which was reverted in 5ab5e2e6731a9f1198df6c53134545ccc6a6bbd3 because it [introduced a regression in `zig run`](https://github.com/ziglang/zig/pull/10950#issuecomment-1049481212) where the runtime arguments passed were incorrect. I've fixed the issue, and notably this was the only location where we directly relied on accessing arguments by index in this code still (all other locations use the iterator proper) and so we should be all good to go now. Signed-off-by: Stephen Gutekanst --- src/main.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.zig b/src/main.zig index 958849f0a5..3f4d124f00 100644 --- a/src/main.zig +++ b/src/main.zig @@ -799,9 +799,9 @@ fn buildOutputType( return cleanExit(); } else if (mem.eql(u8, arg, "--")) { if (arg_mode == .run) { - // The index refers to all_args so skip `zig` `run` - // and `--` - runtime_args_start = args_iter.i + 3; + // args_iter.i is 1, referring the next arg after "--" in ["--", ...] + // Add +2 to the index so it is relative to all_args + runtime_args_start = args_iter.i + 2; break :args_loop; } else { fatal("unexpected end-of-parameter mark: --", .{});