From fd219ab303c2d10b1df9f76c27f4d12814d777ed Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Fri, 23 Feb 2024 03:05:44 -0800 Subject: [PATCH] fix: determine OS at runtime (not compile time) --- crates/bws/src/main.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index 0b714e65b8..c4fd85e87b 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -670,20 +670,12 @@ async fn process_commands() -> Result<()> { } } - let user_command = if command.is_empty() { - let mut buffer = String::new(); - std::io::stdin().read_to_string(&mut buffer)?; - buffer - } else { - command.join(" ") - }; - - let shell = if cfg!(unix) { - shell.unwrap_or_else(|| "sh".to_string()) - } else if cfg!(windows) { - shell.unwrap_or_else(|| "powershell".to_string()) - } else { - unreachable!(); + let shell = match std::env::consts::OS { + os if os == "linux" || os == "macos" || os.contains("bsd") => { + shell.unwrap_or_else(|| "sh".to_string()) + } + "windows" => shell.unwrap_or_else(|| "powershell".to_string()), + _ => unreachable!(), }; let mut command = process::Command::new(shell);