Skip to content

Commit

Permalink
Cancel sudo loop after sudo fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganamilo committed Apr 18, 2021
1 parent cd2049a commit acbcfc1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/exec.rs
Expand Up @@ -62,14 +62,15 @@ fn sudo_loop<S: AsRef<OsStr>>(sudo: &str, flags: &[S]) -> Result<()> {
}

fn update_sudo<S: AsRef<OsStr>>(sudo: &str, flags: &[S]) -> Result<()> {
Command::new(sudo).args(flags).status().with_context(|| {
let ret = Command::new(sudo).args(flags).status().with_context(|| {
let flags = flags
.iter()
.map(|s| s.as_ref().to_string_lossy().into_owned())
.collect::<Vec<_>>()
.join(" ");
format!("failed to run: {} {}", sudo, flags)
})?;
Status(ret.code().unwrap_or(1)).success()?;
Ok(())
}

Expand Down

0 comments on commit acbcfc1

Please sign in to comment.