1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

cp: correctly copy ancestor dirs in --parents mode

Fix a bug where `cp` failed to copy ancestor directories when using
the `--parents` option. For example, before this commit:

    $ mkdir -p a/b/c d
    $ cp --parents a/b/c d
    $ find d
    d
    d/c

After this commit

    $ mkdir -p a/b/c d
    $ cp --parents a/b/c d
    $ find d
    d
    d/a
    d/a/b
    d/a/b/c

This commit also adds the correct messages for `--verbose` mode:

    $ cp -r --parents --verbose a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'

Fixes #3332.
This commit is contained in:
Jeffrey Finkelstein 2022-09-01 22:12:16 -04:00
parent cd3f7b89a7
commit ac3fcca6c0
2 changed files with 34 additions and 0 deletions

View file

@ -1999,6 +1999,19 @@ fn test_copy_same_symlink_no_dereference_dangling() {
ucmd.args(&["-d", "a", "b"]).succeeds();
}
#[cfg(not(windows))]
#[test]
fn test_cp_parents_2_dirs() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir_all("a/b/c");
at.mkdir("d");
ucmd.args(&["-a", "--parents", "a/b/c", "d"])
.succeeds()
.no_stderr()
.no_stdout();
assert!(at.dir_exists("d/a/b/c"));
}
#[test]
#[ignore = "issue #3332"]
fn test_cp_parents_2() {