Skip to content

Commit

Permalink
fix: determine OS at runtime (not compile time)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangowithfoxtrot committed Mar 1, 2024
1 parent 685dfab commit fd219ab
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions crates/bws/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fd219ab

Please sign in to comment.