From 2e79b5c63dbb1ce8950e16990a8951d0c5e325fb Mon Sep 17 00:00:00 2001 From: widberg Date: Thu, 4 Jan 2024 21:24:24 -0500 Subject: [PATCH] Use `cmd.exe` instead of `sh` on Windows --- src/termio/Exec.zig | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index be8a6678f..04ea9293b 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -1090,14 +1090,21 @@ const Subprocess = struct { break :args try args.toOwnedSlice(); } - // We run our shell wrapped in `/bin/sh` so that we don't have - // to parse the commadnd line ourselves if it has arguments. - // Additionally, some environments (NixOS, I found) use /bin/sh - // to setup some environment variables that are important to - // have set. - try args.append("/bin/sh"); - if (internal_os.isFlatpak()) try args.append("-l"); - try args.append("-c"); + if (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"); + try args.append("/C"); + } else { + // We run our shell wrapped in `/bin/sh` so that we don't have + // to parse the command line ourselves if it has arguments. + // Additionally, some environments (NixOS, I found) use /bin/sh + // to setup some environment variables that are important to + // have set. + try args.append("/bin/sh"); + if (internal_os.isFlatpak()) try args.append("-l"); + try args.append("-c"); + } try args.append(opts.full_config.command orelse default_path); break :args try args.toOwnedSlice(); };