Skip to content

Commit 8c406d7

Browse files
authored
Gedding rid out a lot of 2>/dev/full abort (#10646)
1 parent 5827095 commit 8c406d7

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/uucore/src/lib/macros.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ macro_rules! show(
9191
use $crate::error::UError;
9292
let e = $err;
9393
$crate::error::set_exit_code(e.code());
94-
eprintln!("{}: {e}", $crate::util_name());
94+
use std::io::Write as _;
95+
let _ = writeln!(std::io::stderr().lock(), "{}: {e}", $crate::util_name());
9596
})
9697
);
9798

@@ -151,8 +152,10 @@ macro_rules! show_if_err(
151152
#[macro_export]
152153
macro_rules! show_error(
153154
($($args:tt)+) => ({
154-
eprint!("{}: ", $crate::util_name());
155-
eprintln!($($args)+);
155+
use std::io::Write as _;
156+
let mut error = std::io::stderr().lock();
157+
let _ = write!(error, "{}: ", $crate::util_name());
158+
let _ = writeln!(error, $($args)+);
156159
})
157160
);
158161

@@ -174,16 +177,20 @@ macro_rules! show_error(
174177
#[macro_export]
175178
macro_rules! show_warning(
176179
($($args:tt)+) => ({
177-
eprint!("{}: warning: ", $crate::util_name());
178-
eprintln!($($args)+);
180+
use std::io::Write as _;
181+
let mut error = std::io::stderr().lock();
182+
let _ = write!(error, "{}: warning: ", $crate::util_name());
183+
let _ = writeln!(error, $($args)+);
179184
})
180185
);
181186

182187
/// Print a warning message to stderr, prepending the utility name.
183188
#[macro_export]
184189
macro_rules! show_warning_caps(
185190
($($args:tt)+) => ({
186-
eprint!("{}: WARNING: ", $crate::util_name());
187-
eprintln!($($args)+);
191+
use std::io::Write as _;
192+
let mut error = std::io::stderr().lock();
193+
let _ = write!(error, "{}: WARNING: ", $crate::util_name());
194+
let _ = writeln!(error, $($args)+);
188195
})
189196
);

0 commit comments

Comments
 (0)