Skip to content

Commit

Permalink
Avoid sigpipe errors without pulling in libc
Browse files Browse the repository at this point in the history
Signed-off-by: clux <sszynrae@gmail.com>
  • Loading branch information
clux committed Mar 6, 2024
1 parent a6badaa commit f18ab49
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion yq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ fn main() -> Result<()> {
let f = args.file.unwrap(); // required
std::fs::write(f, output + "\n")?;
} else {
println!("{}", output);
// write result to stdout ignoring SIGPIPE errors
// https://github.com/rust-lang/rust/issues/46016
let _ = writeln!(std::io::stdout(), "{output}");
}
Ok(())
}
Expand Down

0 comments on commit f18ab49

Please sign in to comment.