mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Handle broken pipe errors on stdout gracefully (#932)
Replace `println!` calls on the results paths with `writeln!` on `io::stdout()` and propagate the `io::Error` to `main`, where `ErrorKind::BrokenPipe` is turned into a quiet `exit(0)`. This matches the conventional behavior of command-line tools when their output pipe is closed early (e.g. `hyperfine ... | head -n 0`), and fixes panics in all run-output paths: the per-benchmark header and results, the speed comparison summary, and `-`-style exports to stdout. The warnings and "Note" outputs to stderr are converted the same way. --------- Co-authored-by: Mathjk <Mathjk@users.noreply.github.com> Co-authored-by: David Peter <mail@david-peter.de>
This commit is contained in:
7 files changed
+118
-30
No files matched your search
@@ -3,6 +3,10 @@ use std::num::{self, ParseFloatError, ParseIntError};
|
||||
use rust_decimal::Error as DecimalError;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[error(transparent)]
|
||||
pub struct ConsoleOutputError(pub std::io::Error);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ParameterScanError {
|
||||
#[error("Error while parsing parameter scan arguments ({0})")]
|
||||
|
||||
Reference in new issue
Block a user