Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Made stdout go to /dev/null
Browse files Browse the repository at this point in the history
  • Loading branch information
jspspike committed Aug 12, 2020
1 parent 886f12d commit a3656a9
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/terminal/browser.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
use std::process::Command;
use std::process::{Command, Stdio};

pub fn open_browser(url: &str) -> Result<(), failure::Error> {
if cfg!(target_os = "windows") {
let url_escaped = url.replace("&", "^&");
let windows_cmd = format!("start {}", url_escaped);
Command::new("cmd").args(&["/C", &windows_cmd]).spawn()?;
Command::new("cmd")
.args(&["/C", &windows_cmd])
.stdout(Stdio::null())
.spawn()?;
} else if cfg!(target_os = "linux") {
let linux_cmd = format!(r#"xdg-open "{}""#, url);
Command::new("sh").arg("-c").arg(&linux_cmd).spawn()?;
Command::new("sh")
.arg("-c")
.arg(&linux_cmd)
.stdout(Stdio::null())
.spawn()?;
} else {
let mac_cmd = format!(r#"open "{}""#, url);
Command::new("sh").arg("-c").arg(&mac_cmd).spawn()?;
Command::new("sh")
.arg("-c")
.arg(&mac_cmd)
.stdout(Stdio::null())
.spawn()?;
};

Ok(())
Expand Down

0 comments on commit a3656a9

Please sign in to comment.