1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

cp: fix warnings from unnecessary_debug_formatting

Co-authored-by: Jeremy Smart <jeremy3141592@gmail.com>
This commit is contained in:
Daniel Hofstetter 2025-05-19 09:37:52 +02:00
parent 7a706b5756
commit 8674e86703
3 changed files with 19 additions and 11 deletions

View file

@ -1259,13 +1259,17 @@ fn parse_path_args(
return Err("missing file operand".into()); return Err("missing file operand".into());
} else if paths.len() == 1 && options.target_dir.is_none() { } else if paths.len() == 1 && options.target_dir.is_none() {
// Only one file specified // Only one file specified
return Err(format!("missing destination file operand after {:?}", paths[0]).into()); return Err(format!(
"missing destination file operand after {}",
paths[0].display().to_string().quote()
)
.into());
} }
// Return an error if the user requested to copy more than one // Return an error if the user requested to copy more than one
// file source to a file target // file source to a file target
if options.no_target_dir && options.target_dir.is_none() && paths.len() > 2 { if options.no_target_dir && options.target_dir.is_none() && paths.len() > 2 {
return Err(format!("extra operand {:?}", paths[2]).into()); return Err(format!("extra operand {:}", paths[2].display().to_string().quote()).into());
} }
let target = match options.target_dir { let target = match options.target_dir {

View file

@ -84,7 +84,12 @@ pub(crate) fn copy_on_write(
// support COW). // support COW).
match reflink_mode { match reflink_mode {
ReflinkMode::Always => { ReflinkMode::Always => {
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into()); return Err(format!(
"failed to clone {} from {}: {error}",
source.display(),
dest.display()
)
.into());
} }
_ => { _ => {
copy_debug.reflink = OffloadReflinkDebug::Yes; copy_debug.reflink = OffloadReflinkDebug::Yes;

View file

@ -2,13 +2,12 @@
// //
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs neve ROOTDIR USERDIR procfs outfile uufs xattrs // spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs neve ROOTDIR USERDIR procfs outfile uufs xattrs
// spell-checker:ignore bdfl hlsl IRWXO IRWXG nconfined matchpathcon libselinux-devel // spell-checker:ignore bdfl hlsl IRWXO IRWXG nconfined matchpathcon libselinux-devel
use uutests::at_and_ucmd; use uucore::display::Quotable;
use uutests::new_ucmd;
use uutests::path_concat;
use uutests::util::TestScenario; use uutests::util::TestScenario;
use uutests::util_name; use uutests::{at_and_ucmd, new_ucmd, path_concat, util_name};
#[cfg(not(windows))] #[cfg(not(windows))]
use std::fs::set_permissions; use std::fs::set_permissions;
@ -3946,10 +3945,10 @@ fn test_cp_only_source_no_target() {
let ts = TestScenario::new(util_name!()); let ts = TestScenario::new(util_name!());
let at = &ts.fixtures; let at = &ts.fixtures;
at.touch("a"); at.touch("a");
ts.ucmd() ts.ucmd().arg("a").fails().stderr_contains(format!(
.arg("a") "missing destination file operand after {}",
.fails() "a".quote()
.stderr_contains("missing destination file operand after \"a\""); ));
} }
#[test] #[test]