Skip to content

Commit

Permalink
cp: improve error msg if -r is not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
cakebaker committed Nov 20, 2023
1 parent 02dc6ee commit 285e580
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/uu/cp/src/copydir.rs
Expand Up @@ -324,7 +324,7 @@ pub(crate) fn copy_directory(
source_in_command_line: bool,
) -> CopyResult<()> {
if !options.recursive {
return Err(format!("omitting directory {}", root.quote()).into());
return Err(format!("-r not specified; omitting directory {}", root.quote()).into());
}

// if no-dereference is enabled and this is a symlink, copy it as a file
Expand Down
4 changes: 3 additions & 1 deletion tests/by-util/test_cp.rs
Expand Up @@ -131,7 +131,9 @@ fn test_cp_directory_not_recursive() {
.arg(TEST_COPY_TO_FOLDER)
.arg(TEST_HELLO_WORLD_DEST)
.fails()
.stderr_contains("omitting directory");
.stderr_is(format!(
"cp: -r not specified; omitting directory '{TEST_COPY_TO_FOLDER}'\n"
));
}

#[test]
Expand Down

0 comments on commit 285e580

Please sign in to comment.