diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-10-02 18:20:55 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-10-06 19:31:57 -0400 |
| commit | 87807d53dd711d0452e6e963243986c7d885e987 (patch) | |
| tree | 14bd3385367dab1f430535323e324818e9e3f9a5 /src/main.zig | |
| parent | 58502b8bfec51f04ad12ec65b0d52452e179256a (diff) | |
| download | zig-87807d53dd711d0452e6e963243986c7d885e987.tar.gz zig-87807d53dd711d0452e6e963243986c7d885e987.zip | |
stage2: Fix arg processing for zig run
* Stop parsing arguments after `--`
* Calculate the correct index for the first argument after `--`
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.zig b/src/main.zig index cd8fefce87..7564342739 100644 --- a/src/main.zig +++ b/src/main.zig @@ -525,7 +525,7 @@ fn buildOutputType( //} const args = all_args[2..]; var i: usize = 0; - while (i < args.len) : (i += 1) { + args_loop: while (i < args.len) : (i += 1) { const arg = args[i]; if (mem.startsWith(u8, arg, "-")) { if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { @@ -533,7 +533,10 @@ fn buildOutputType( return cleanExit(); } else if (mem.eql(u8, arg, "--")) { if (arg_mode == .run) { - runtime_args_start = i + 1; + // The index refers to all_args so skip `zig` `run` + // and `--` + runtime_args_start = i + 3; + break :args_loop; } else { fatal("unexpected end-of-parameter mark: --", .{}); } |
