mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 23:02:31 +00:00
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
This commit is contained in:
parent
a4137d639a
commit
329fe4a24b
1 changed files with 4 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue