From 329fe4a24b70c86ce5c0efbb6e679ab5032865b2 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 18 Aug 2021 10:16:55 -0500 Subject: [PATCH] fix: Swallow broken pipes Previously, we paniced. This is one less reason people have to call lower level `get_matches` to get the commonly expected behavior, making it more likely for the Rust community to "do the right thing" Fixes #2659 --- src/parse/errors.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/parse/errors.rs b/src/parse/errors.rs index df3912a5..da0c7d5f 100644 --- a/src/parse/errors.rs +++ b/src/parse/errors.rs @@ -478,11 +478,13 @@ impl Error { /// or prints to `stdout` and exits with a status of `0`. pub fn exit(&self) -> ! { if self.use_stderr() { - self.message.print().expect("Error writing Error to stderr"); + // Swallow broken pipe errors + let _ = self.message.print(); safe_exit(USAGE_CODE); } - self.message.print().expect("Error writing Error to stdout"); + // Swallow broken pipe errors + let _ = self.message.print(); safe_exit(SUCCESS_CODE) }