true, false: Fix broken pipe (#11204)

This commit is contained in:
oech3
2026-03-06 09:40:53 +01:00
committed by GitHub
parent 4a5384e184
commit 70e07a3c4b
2 changed files with 6 additions and 4 deletions
+3 -2
View File
@@ -7,7 +7,6 @@ use std::{ffi::OsString, io::Write};
use uucore::translate;
// uucore::main does not support no-result
// also remove SIGPIPE overhead
pub fn uumain(args: impl uucore::Args) -> i32 {
let args: Vec<OsString> = args.collect();
if args.len() != 2 {
@@ -23,7 +22,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
return 1;
};
if let Err(print_fail) = error {
if let Err(print_fail) = error
&& print_fail.kind() != std::io::ErrorKind::BrokenPipe
{
let _ = writeln!(std::io::stderr(), "{}: {print_fail}", uucore::util_name());
}
1
+3 -2
View File
@@ -7,7 +7,6 @@ use std::{ffi::OsString, io::Write};
use uucore::translate;
// uucore::main does not support no-result
// also remove SIGPIPE overhead
pub fn uumain(args: impl uucore::Args) -> i32 {
let args: Vec<OsString> = args.collect();
if args.len() != 2 {
@@ -23,7 +22,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
return 0;
};
if let Err(print_fail) = error {
if let Err(print_fail) = error
&& print_fail.kind() != std::io::ErrorKind::BrokenPipe
{
// Try to display this error.
let _ = writeln!(std::io::stderr(), "{}: {print_fail}", uucore::util_name());
// Mirror GNU options. When failing to print warnings or version flags, then we exit