From 8797eecc1bb6c917e5578e0cc086c614a8282c18 Mon Sep 17 00:00:00 2001 From: FidelSch Date: Tue, 10 Feb 2026 15:53:53 -0300 Subject: [PATCH] fix(numfmt): do not panic on failure to print --- src/uu/numfmt/src/format.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/uu/numfmt/src/format.rs b/src/uu/numfmt/src/format.rs index b6946cdf8c4..ab67dfaa271 100644 --- a/src/uu/numfmt/src/format.rs +++ b/src/uu/numfmt/src/format.rs @@ -1,3 +1,5 @@ +use std::io::{Write, stdout}; + // This file is part of the uutils coreutils package. // // For the full copyright and license information, please view the LICENSE @@ -479,7 +481,7 @@ pub fn format_and_print_delimited(input: &[u8], options: &NumfmtOptions) -> Resu } output.push(eol); - std::io::Write::write_all(&mut std::io::stdout(), &output).map_err(|e| e.to_string())?; + stdout().write_all(&output).map_err(|e| e.to_string())?; Ok(()) } @@ -523,7 +525,9 @@ pub fn format_and_print_whitespace(s: &str, options: &NumfmtOptions) -> Result<( let eol = if options.zero_terminated { '\0' } else { '\n' }; output.push(eol); - print!("{output}"); + stdout() + .write_all(output.as_bytes()) + .map_err(|e| e.to_string())?; Ok(()) }