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

check_cmd: Actually check the subcommand exit code. #30

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ pub mod ssh;
pub mod terraform;
pub mod types;

use anyhow::Result;
use error::Error;

use anyhow::Context;
use anyhow::{anyhow, Context, Result};
use execute::Execute;
use log::debug;
use std::env;
Expand Down Expand Up @@ -67,9 +66,16 @@ pub fn sh(command: std::process::Command) -> Result<String> {

fn check_cmd(cmd: &mut Command) -> Result<()> {
println!("run: {:?}", cmd);
cmd.status()?;

Ok(())
let status = cmd.status()?;
if status.success() {
Ok(())
} else {
Err(anyhow!(
"{:?} failed with non-zero exit code {:?}",
cmd,
status
))
}
}

#[derive(Clone)]
Expand Down