Ignore EPIPE silently

fixes a regression introduced in a6aeabfde4

closes #181
This commit is contained in:
David Peter committed 2022-12-05 09:30:13 +01:00
1 parent 2d8b600c48
commit 8577a17b14
1 file changed
+8 -3
+8 -3
View File
@@ -11,7 +11,7 @@ use clap::{crate_name, crate_version, Arg, ArgAction, ColorChoice, Command};
use is_terminal::IsTerminal;
use anyhow::{anyhow, Context, Error as AnyhowError};
use anyhow::{anyhow, Context, Result};
use const_format::formatcp;
@@ -23,7 +23,7 @@ use hexyl::{Base, BorderStyle, Input, PrinterBuilder};
const DEFAULT_BLOCK_SIZE: i64 = 512;
fn run() -> Result<(), AnyhowError> {
fn run() -> Result<()> {
let command = Command::new(crate_name!())
.color(ColorChoice::Auto)
.max_term_width(90)
@@ -268,7 +268,7 @@ fn run() -> Result<(), AnyhowError> {
0
};
let parse_byte_count = |s| -> Result<u64, AnyhowError> {
let parse_byte_count = |s| -> Result<u64> {
Ok(parse_byte_offset(s, block_size)?
.assume_forward_offset_from_start()?
.into())
@@ -444,6 +444,11 @@ fn main() {
let result = run();
if let Err(err) = result {
if let Some(io_error) = err.downcast_ref::<io::Error>() {
if io_error.kind() == ::std::io::ErrorKind::BrokenPipe {
std::process::exit(0);
}
}
eprintln!("Error: {:?}", err);
std::process::exit(1);
}