Skip to content

Commit 8d51774

Browse files
committed
remove eprintln! to avoid 2>/dev/full SIGABRT
1 parent 1266b7f commit 8d51774

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/find/matchers/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use ls::Ls;
6565
use std::{
6666
error::Error,
6767
fs::{File, Metadata},
68-
io::Read,
68+
io::{stderr, Read, Write},
6969
path::Path,
7070
str::FromStr,
7171
time::SystemTime,
@@ -1002,7 +1002,7 @@ fn parse_files0_args(config: &mut Config) -> Result<(), Box<dyn Error>> {
10021002
.collect();
10031003
// empty starting point checker
10041004
if string_segments.iter().any(|s| s.is_empty()) {
1005-
eprintln!("find: invalid zero-length file name");
1005+
let _ = writeln!(stderr(), "find: invalid zero-length file name");
10061006
// remove the empty ones so as to avoid file not found error
10071007
string_segments.retain(|s| !s.is_empty());
10081008
}

src/find/matchers/printf.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ use std::error::Error;
88
use std::fs::{self, File};
99
use std::path::Path;
1010
use std::time::SystemTime;
11-
use std::{borrow::Cow, io::Write};
11+
use std::{
12+
borrow::Cow,
13+
io::{stderr, Write},
14+
};
1215

1316
use chrono::{format::StrftimeItems, DateTime, Local};
1417

@@ -608,7 +611,8 @@ impl Printf {
608611
}
609612
}
610613
Err(e) => {
611-
eprintln!(
614+
let _ = writeln!(
615+
stderr(),
612616
"Error processing '{}': {}",
613617
file_info.path().to_string_lossy(),
614618
e

src/xargs/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{
1010
ffi::{OsStr, OsString},
1111
fmt::Display,
1212
fs,
13-
io::{self, BufRead, BufReader, Read},
13+
io::{self, stderr, BufRead, BufReader, Read, Write},
1414
process::{Command, Stdio},
1515
};
1616

@@ -439,7 +439,7 @@ impl CommandBuilder<'_> {
439439
}
440440

441441
if self.options.verbose {
442-
eprintln!("{command:?}");
442+
let _ = writeln!(stderr(), "{command:?}");
443443
}
444444

445445
match &self.options.action {
@@ -827,7 +827,7 @@ fn normalize_options(options: Options, matches: &clap::ArgMatches) -> Options {
827827
(options.max_args, options.max_lines, None)
828828
}
829829
_ => {
830-
eprintln!(
830+
let _ = writeln!(stderr(),
831831
"WARNING: -L, -n and -I/-i are mutually exclusive, but more than one were given; \
832832
only the last option will be used"
833833
);
@@ -1154,7 +1154,7 @@ pub fn xargs_main(args: &[&str]) -> i32 {
11541154
Ok(CommandResult::Success) => 0,
11551155
Ok(CommandResult::Failure) => 123,
11561156
Err(e) => {
1157-
eprintln!("Error: {e}");
1157+
let _ = writeln!(stderr(), "Error: {e}");
11581158
if let XargsError::CommandExecution(cx) = e {
11591159
match cx {
11601160
CommandExecutionError::UrgentlyFailed => 124,

0 commit comments

Comments
 (0)