From f68e8f118fc7c161bafda580ac5ffd712f8d2aec Mon Sep 17 00:00:00 2001 From: Rashil Gandhi Date: Sat, 27 Nov 2021 00:47:33 +0530 Subject: [PATCH] add handling for cmd custom commands --- src/modules/custom.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modules/custom.rs b/src/modules/custom.rs index f731d9679..3385f6f40 100644 --- a/src/modules/custom.rs +++ b/src/modules/custom.rs @@ -161,6 +161,7 @@ fn shell_command(cmd: &str, shell_args: &[&str]) -> Option { .stderr(Stdio::piped()); handle_powershell(&mut command, &forced_shell, shell_args); + handle_cmd(&mut command, &forced_shell, shell_args); if let Ok(mut child) = command.spawn() { child.stdin.as_mut()?.write_all(cmd.as_bytes()).ok()?; @@ -247,6 +248,15 @@ fn handle_powershell(command: &mut Command, shell: &str, shell_args: &[&str]) { } } +#[cfg(windows)] +fn handle_cmd(command: &mut Command, shell: &str, shell_args: &[&str]) { + let is_cmd = shell.ends_with("cmd.exe") || shell.ends_with("cmd"); + + if is_cmd && shell_args.is_empty() { + command.arg("/C"); + } +} + #[cfg(test)] mod tests { use super::*;