diff options
| author | Michaƫl Larouche <michael.larouche@gmail.com> | 2020-01-10 19:25:26 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-01-14 15:12:30 -0500 |
| commit | 7ee0e779af1f9b457afee259a4137e928e9627f8 (patch) | |
| tree | dac82e99efb3f5c90d0f11eccca297d836ca95f1 /lib | |
| parent | 505b9db9090c7decba68c7882b1330f48aff0c10 (diff) | |
| download | zig-7ee0e779af1f9b457afee259a4137e928e9627f8.tar.gz zig-7ee0e779af1f9b457afee259a4137e928e9627f8.zip | |
Fix std.child_process.ChildProcess.spawnWindow when looking in PATH environment variable, it applied cwd+app_name instead of just using the app_name
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/child_process.zig | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index 6106a88942..ab99abe28a 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -592,7 +592,7 @@ pub const ChildProcess = struct { // the cwd set in ChildProcess is in effect when choosing the executable path // to match posix semantics - const app_name = x: { + const app_path = x: { if (self.cwd) |cwd| { const resolved = try fs.path.resolve(self.allocator, &[_][]const u8{ cwd, self.argv[0] }); defer self.allocator.free(resolved); @@ -601,15 +601,15 @@ pub const ChildProcess = struct { break :x try cstr.addNullByte(self.allocator, self.argv[0]); } }; - defer self.allocator.free(app_name); + defer self.allocator.free(app_path); - const app_name_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, app_name); - defer self.allocator.free(app_name_w); + const app_path_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, app_path); + defer self.allocator.free(app_path_w); const cmd_line_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, cmd_line); defer self.allocator.free(cmd_line_w); - windowsCreateProcess(app_name_w.ptr, cmd_line_w.ptr, envp_ptr, cwd_w_ptr, &siStartInfo, &piProcInfo) catch |no_path_err| { + windowsCreateProcess(app_path_w.ptr, cmd_line_w.ptr, envp_ptr, cwd_w_ptr, &siStartInfo, &piProcInfo) catch |no_path_err| { if (no_path_err != error.FileNotFound) return no_path_err; var free_path = true; @@ -632,6 +632,8 @@ pub const ChildProcess = struct { }; defer if (free_path_ext) self.allocator.free(PATHEXT); + const app_name = self.argv[0]; + var it = mem.tokenize(PATH, ";"); retry: while (it.next()) |search_path| { const path_no_ext = try fs.path.join(self.allocator, &[_][]const u8{ search_path, app_name }); |
