Skip to content

Commit

Permalink
cp: allow multiple usages of -R - Closes: uutils#5027
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre committed Jul 3, 2023
1 parent 42bf580 commit 5025d67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,9 @@ pub fn uu_app() -> Command {
.long(options::RECURSIVE)
// --archive sets this option
.help("copy directories recursively")
.action(ArgAction::SetTrue),
.action(ArgAction::SetTrue)
// Allow several declarations
.overrides_with(options::RECURSIVE),
)
.arg(
Arg::new(options::STRIP_TRAILING_SLASHES)
Expand Down
14 changes: 14 additions & 0 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
Expand Down

0 comments on commit 5025d67

Please sign in to comment.