Skip to content
This repository was archived by the owner on Apr 7, 2022. It is now read-only.

Commit 785b71f

Browse files
authored
Merge pull request #30 from shlevy/check_cmd-actually-check
check_cmd: Actually check the subcommand exit code.
2 parents e579aa4 + c47f4a5 commit 785b71f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/src/lib.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ pub mod ssh;
88
pub mod terraform;
99
pub mod types;
1010

11-
use anyhow::Result;
1211
use error::Error;
1312

14-
use anyhow::Context;
13+
use anyhow::{anyhow, Context, Result};
1514
use execute::Execute;
1615
use log::debug;
1716
use std::env;
@@ -67,9 +66,16 @@ pub fn sh(command: std::process::Command) -> Result<String> {
6766

6867
fn check_cmd(cmd: &mut Command) -> Result<()> {
6968
println!("run: {:?}", cmd);
70-
cmd.status()?;
71-
72-
Ok(())
69+
let status = cmd.status()?;
70+
if status.success() {
71+
Ok(())
72+
} else {
73+
Err(anyhow!(
74+
"{:?} failed with non-zero exit code {:?}",
75+
cmd,
76+
status
77+
))
78+
}
7379
}
7480

7581
#[derive(Clone)]

0 commit comments

Comments
 (0)