From 70e07a3c4b59adee0502323490873346c0569e6b Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Fri, 6 Mar 2026 17:40:53 +0900 Subject: [PATCH] true, false: Fix broken pipe (#11204) --- src/uu/false/src/false.rs | 5 +++-- src/uu/true/src/true.rs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/uu/false/src/false.rs b/src/uu/false/src/false.rs index 0fc90364a..98699edd0 100644 --- a/src/uu/false/src/false.rs +++ b/src/uu/false/src/false.rs @@ -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 = 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 diff --git a/src/uu/true/src/true.rs b/src/uu/true/src/true.rs index 626073c21..463a76d52 100644 --- a/src/uu/true/src/true.rs +++ b/src/uu/true/src/true.rs @@ -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 = 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