Skip to content

Commit 8674e86

Browse files
cakebakerQelxiros
andcommitted
cp: fix warnings from unnecessary_debug_formatting
Co-authored-by: Jeremy Smart <jeremy3141592@gmail.com>
1 parent 7a706b5 commit 8674e86

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/uu/cp/src/cp.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,13 +1259,17 @@ fn parse_path_args(
12591259
return Err("missing file operand".into());
12601260
} else if paths.len() == 1 && options.target_dir.is_none() {
12611261
// Only one file specified
1262-
return Err(format!("missing destination file operand after {:?}", paths[0]).into());
1262+
return Err(format!(
1263+
"missing destination file operand after {}",
1264+
paths[0].display().to_string().quote()
1265+
)
1266+
.into());
12631267
}
12641268

12651269
// Return an error if the user requested to copy more than one
12661270
// file source to a file target
12671271
if options.no_target_dir && options.target_dir.is_none() && paths.len() > 2 {
1268-
return Err(format!("extra operand {:?}", paths[2]).into());
1272+
return Err(format!("extra operand {:}", paths[2].display().to_string().quote()).into());
12691273
}
12701274

12711275
let target = match options.target_dir {

src/uu/cp/src/platform/macos.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ pub(crate) fn copy_on_write(
8484
// support COW).
8585
match reflink_mode {
8686
ReflinkMode::Always => {
87-
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into());
87+
return Err(format!(
88+
"failed to clone {} from {}: {error}",
89+
source.display(),
90+
dest.display()
91+
)
92+
.into());
8893
}
8994
_ => {
9095
copy_debug.reflink = OffloadReflinkDebug::Yes;

tests/by-util/test_cp.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
//
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
5+
56
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs neve ROOTDIR USERDIR procfs outfile uufs xattrs
67
// spell-checker:ignore bdfl hlsl IRWXO IRWXG nconfined matchpathcon libselinux-devel
7-
use uutests::at_and_ucmd;
8-
use uutests::new_ucmd;
9-
use uutests::path_concat;
8+
use uucore::display::Quotable;
109
use uutests::util::TestScenario;
11-
use uutests::util_name;
10+
use uutests::{at_and_ucmd, new_ucmd, path_concat, util_name};
1211

1312
#[cfg(not(windows))]
1413
use std::fs::set_permissions;
@@ -3946,10 +3945,10 @@ fn test_cp_only_source_no_target() {
39463945
let ts = TestScenario::new(util_name!());
39473946
let at = &ts.fixtures;
39483947
at.touch("a");
3949-
ts.ucmd()
3950-
.arg("a")
3951-
.fails()
3952-
.stderr_contains("missing destination file operand after \"a\"");
3948+
ts.ucmd().arg("a").fails().stderr_contains(format!(
3949+
"missing destination file operand after {}",
3950+
"a".quote()
3951+
));
39533952
}
39543953

39553954
#[test]

0 commit comments

Comments
 (0)