From 285e580b6eb9475e5d61645594b7a75c13073eed Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 19 Nov 2023 15:59:38 +0100 Subject: [PATCH] cp: improve error msg if -r is not specified --- src/uu/cp/src/copydir.rs | 2 +- tests/by-util/test_cp.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/uu/cp/src/copydir.rs b/src/uu/cp/src/copydir.rs index 763d66c0b03..a903ed2aaff 100644 --- a/src/uu/cp/src/copydir.rs +++ b/src/uu/cp/src/copydir.rs @@ -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 diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index c8761fab8fb..14b68da3718 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -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]