Fixes issue with ohmyzsh returning 80 on a successful run (#570)

This commit is contained in:
Seung-Li Maeda
2020-12-01 19:56:12 -08:00
committed by GitHub
parent 4f3bdcad86
commit f9116dd0f3
3 changed files with 34 additions and 2 deletions

View File

@@ -28,6 +28,22 @@ impl Check for Output {
}
}
pub trait CheckWithCodes {
fn check_with_codes(self, codes: &[i32]) -> Result<()>;
}
impl CheckWithCodes for ExitStatus {
fn check_with_codes(self, codes: &[i32]) -> Result<()> {
// Set the default to be -1 because the option represents a signal termination
let code = self.code().unwrap_or(-1);
if self.success() || codes.contains(&code) {
Ok(())
} else {
Err(TopgradeError::ProcessFailed(self).into())
}
}
}
pub trait PathExt
where
Self: Sized,