Skip to content
Closed
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
8 changes: 6 additions & 2 deletions src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,13 +1259,17 @@ fn parse_path_args(
return Err("missing file operand".into());
} else if paths.len() == 1 && options.target_dir.is_none() {
// 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
// file source to a file target
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 {
Expand Down
7 changes: 6 additions & 1 deletion src/uu/cp/src/platform/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ pub(crate) fn copy_on_write(
// support COW).
match reflink_mode {
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;
Expand Down
2 changes: 1 addition & 1 deletion src/uu/ln/src/ln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ enum LnError {
MissingDestination(PathBuf),

#[error("extra operand {}\nTry '{} --help' for more information.",
format!("{_0:?}").trim_matches('"'), _1)]
_0.display(), _1)]
ExtraOperand(OsString, String),
}

Expand Down
2 changes: 1 addition & 1 deletion src/uu/mv/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ fn rename_dir_fallback(
io::ErrorKind::PermissionDenied,
"Permission denied",
)),
_ => Err(io::Error::new(io::ErrorKind::Other, format!("{err:?}"))),
_ => Err(io::Error::other(format!("{err:?}"))),
},
_ => Ok(()),
}
Expand Down
9 changes: 5 additions & 4 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use uucore::display::Quotable;
// This file is part of the uutils coreutils package.
//
// For the full copyright and license information, please view the LICENSE
Expand Down Expand Up @@ -3946,10 +3947,10 @@ fn test_cp_only_source_no_target() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.touch("a");
ts.ucmd()
.arg("a")
.fails()
.stderr_contains("missing destination file operand after \"a\"");
ts.ucmd().arg("a").fails().stderr_contains(format!(
"missing destination file operand after {}",
"a".quote()
));
}

#[test]
Expand Down
Loading