authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-10-02 18:20:55+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-06 19:31:57-04:00
log87807d53dd711d0452e6e963243986c7d885e987
tree14bd3385367dab1f430535323e324818e9e3f9a5
parent58502b8bfec51f04ad12ec65b0d52452e179256a

stage2: Fix arg processing for zig run

* Stop parsing arguments after `--` * Calculate the correct index for the first argument after `--`

1 files changed, 5 insertions(+), 2 deletions(-)

src/main.zig+5-2
...@@ -525,7 +525,7 @@ fn buildOutputType(...@@ -525,7 +525,7 @@ fn buildOutputType(
525 //}525 //}
526 const args = all_args[2..];526 const args = all_args[2..];
527 var i: usize = 0;527 var i: usize = 0;
528 while (i < args.len) : (i += 1) {528 args_loop: while (i < args.len) : (i += 1) {
529 const arg = args[i];529 const arg = args[i];
530 if (mem.startsWith(u8, arg, "-")) {530 if (mem.startsWith(u8, arg, "-")) {
531 if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {531 if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
...@@ -533,7 +533,10 @@ fn buildOutputType(...@@ -533,7 +533,10 @@ fn buildOutputType(
533 return cleanExit();533 return cleanExit();
534 } else if (mem.eql(u8, arg, "--")) {534 } else if (mem.eql(u8, arg, "--")) {
535 if (arg_mode == .run) {535 if (arg_mode == .run) {
536 runtime_args_start = i + 1;536 // The index refers to all_args so skip `zig` `run`
537 // and `--`
538 runtime_args_start = i + 3;
539 break :args_loop;
537 } else {540 } else {
538 fatal("unexpected end-of-parameter mark: --", .{});541 fatal("unexpected end-of-parameter mark: --", .{});
539 }542 }