Skip to content

Commit

Permalink
Don't print an error if the pipe is closed (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderThaller committed Sep 2, 2021
1 parent 00399de commit 94c7c51
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ use structopt::StructOpt;
fn main() {
let opt = Opt::from_args();

if let Err(err) = opt.run() {
error!("{}", err);
match opt.run() {
Err(run::Error::WriteStdout(io_err)) => {
// If pipe is closed we can savely ignore that error
if io_err.kind() == std::io::ErrorKind::BrokenPipe {}
}

Err(err) => error!("{}", err),

Ok(_) => (),
}
}
2 changes: 2 additions & 0 deletions src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ pub fn default_no_format(display: &TableDisplay, entries: Vec<Entry>) -> Result<
handle
.write_all(header.join("\t").as_bytes())
.map_err(Error::WriteStdout)?;

handle.write_all(b"\n").map_err(Error::WriteStdout)?;
}

Expand Down Expand Up @@ -212,6 +213,7 @@ pub fn default_no_format(display: &TableDisplay, entries: Vec<Entry>) -> Result<
handle
.write_all(row.join("\t").as_bytes())
.map_err(Error::WriteStdout)?;

handle.write_all(b"\n").map_err(Error::WriteStdout)?;
}

Expand Down

0 comments on commit 94c7c51

Please sign in to comment.