From de71e992ec8a7135d352d213e7382a52b0d577d5 Mon Sep 17 00:00:00 2001 From: widberg Date: Thu, 11 Jan 2024 11:57:25 -0500 Subject: [PATCH] Use WINDIR instead of hardcoding C:\Windows --- src/termio/Exec.zig | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 38aec2929..909a2ce49 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -1042,7 +1042,17 @@ const Subprocess = struct { if (comptime builtin.os.tag == .windows) { // We run our shell wrapped in `cmd.exe` so that we don't have // to parse the command line ourselves if it has arguments. - try args.append("C:\\Windows\\System32\\cmd.exe"); + + // Note we don't free any of the memory below since it is + // allocated in the arena. + const windir = try std.process.getEnvVarOwned(alloc, "WINDIR"); + const cmd = try std.fs.path.join(alloc, &[_][]const u8{ + windir, + "System32", + "cmd.exe", + }); + + try args.append(cmd); try args.append("/C"); } else { // We run our shell wrapped in `/bin/sh` so that we don't have