From e491bbdbed1e0ad45a97ec423780713557c4bb6d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 3 Jul 2023 08:51:23 +0200 Subject: [PATCH] cp: allow multiple usages of -R/-r Closes: #5027 works for all other rm args --- src/uu/cp/src/cp.rs | 1 + tests/by-util/test_cp.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 60ef540954a..de9dd1c919f 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -383,6 +383,7 @@ pub fn uu_app() -> Command { backup_control::BACKUP_CONTROL_LONG_HELP )) .infer_long_args(true) + .args_override_self(true) .arg( Arg::new(options::TARGET_DIRECTORY) .short('t') diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 3074513de2e..4e699367976 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -158,6 +158,20 @@ fn test_cp_recurse() { assert_eq!(at.read(TEST_COPY_TO_FOLDER_NEW_FILE), "Hello, World!\n"); } +#[test] +#[cfg(not(target_os = "macos"))] +fn test_cp_recurse_several() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.arg("-r") + .arg("-r") + .arg(TEST_COPY_FROM_FOLDER) + .arg(TEST_COPY_TO_FOLDER_NEW) + .succeeds(); + + // Check the content of the destination file that was copied. + assert_eq!(at.read(TEST_COPY_TO_FOLDER_NEW_FILE), "Hello, World!\n"); +} + #[test] fn test_cp_with_dirs_t() { let (at, mut ucmd) = at_and_ucmd!();