From 75da247317bf9456bce522a4997c8eaeac263d8a Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Wed, 9 Jun 2021 15:13:14 -0400 Subject: [PATCH] cli: Ignore BrokenPipe errors again With the change to anyhow in the previous commit, we stopped ignoring BrokenPipe errors. Now we do again, not as a core part of our error type, but as part of the `main` functions reaction to any error that occurs. --- cli/src/main.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cli/src/main.rs b/cli/src/main.rs index e80fa550..11ed7c73 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -13,6 +13,19 @@ const BUILD_VERSION: &'static str = env!("CARGO_PKG_VERSION"); const BUILD_SHA: Option<&'static str> = option_env!("BUILD_SHA"); fn main() -> Result<()> { + let result = run(); + // Ignore BrokenPipe errors + if let Err(err) = &result { + if let Some(error) = err.downcast_ref::() { + if error.kind() == std::io::ErrorKind::BrokenPipe { + return Ok(()); + } + } + } + result +} + +fn run() -> Result<()> { let version = if let Some(build_sha) = BUILD_SHA { format!("{} ({})", BUILD_VERSION, build_sha) } else {