mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
true, false: Fix broken pipe (#11204)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user