Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stepancheg committed May 27, 2024
1 parent 4ebb530 commit a51defc
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/sh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ use std::process::Child;
use std::process::Command;
use std::process::Stdio;

#[cfg(not(windows))]
pub fn spawn_sh(script: &str) -> anyhow::Result<Child> {
Ok(Command::new("/bin/sh")
.args(&["-ec", &script])
.stdin(Stdio::null())
.spawn()?)
}

#[cfg(windows)]
pub fn spawn_sh(script: &str) -> anyhow::Result<Child> {
Ok(Command::new("powershell.exe")
.args(&["-Command", &script])
.stdin(Stdio::null())
.spawn()?)
#[cfg(not(windows))]
{
Ok(Command::new("/bin/sh")
.args(&["-ec", &script])
.stdin(Stdio::null())
.spawn()?)
}
#[cfg(windows)]
{
Ok(Command::new("powershell.exe")
.args(&["-Command", &script])
.stdin(Stdio::null())
.spawn()?)
}
}

0 comments on commit a51defc

Please sign in to comment.