Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/find/matchers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use ls::Ls;
use std::{
error::Error,
fs::{File, Metadata},
io::Read,
io::{stderr, Read, Write},
path::Path,
str::FromStr,
time::SystemTime,
Expand Down Expand Up @@ -1002,7 +1002,7 @@ fn parse_files0_args(config: &mut Config) -> Result<(), Box<dyn Error>> {
.collect();
// empty starting point checker
if string_segments.iter().any(|s| s.is_empty()) {
eprintln!("find: invalid zero-length file name");
let _ = writeln!(stderr(), "find: invalid zero-length file name");
// remove the empty ones so as to avoid file not found error
string_segments.retain(|s| !s.is_empty());
}
Expand Down
8 changes: 6 additions & 2 deletions src/find/matchers/printf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ use std::error::Error;
use std::fs::{self, File};
use std::path::Path;
use std::time::SystemTime;
use std::{borrow::Cow, io::Write};
use std::{
borrow::Cow,
io::{stderr, Write},
};

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

Expand Down Expand Up @@ -608,7 +611,8 @@ impl Printf {
}
}
Err(e) => {
eprintln!(
let _ = writeln!(
stderr(),
"Error processing '{}': {}",
file_info.path().to_string_lossy(),
e
Expand Down
8 changes: 4 additions & 4 deletions src/xargs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
ffi::{OsStr, OsString},
fmt::Display,
fs,
io::{self, BufRead, BufReader, Read},
io::{self, stderr, BufRead, BufReader, Read, Write},
process::{Command, Stdio},
};

Expand Down Expand Up @@ -439,7 +439,7 @@ impl CommandBuilder<'_> {
}

if self.options.verbose {
eprintln!("{command:?}");
let _ = writeln!(stderr(), "{command:?}");
}

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