Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cp-parents.sh: cp: recursive copy #3332

Closed
Tracked by #3336
ghost opened this issue Mar 29, 2022 · 10 comments · Fixed by #4184
Closed
Tracked by #3336

cp-parents.sh: cp: recursive copy #3332

ghost opened this issue Mar 29, 2022 · 10 comments · Fixed by #4184
Labels

Comments

@ghost
Copy link

ghost commented Mar 29, 2022

ref: #3320

Below described issue is at least one of the reason why the gnu test tests/cp/cp-parents.sh is in ERROR state.

gnu

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

uutils

> cp --verbose -a --parents a/b/c d 
> ls -al d
total 0
drwxr-xr-x  3 bha_srik_k users  15 Mar 29 12:51 .
drwxr-xr-x 12 bha_srik_k users 178 Mar 29 12:48 ..
drwxr-xr-x  2 bha_srik_k users   6 Mar 29 12:51 c
  1. note that gnu creates the directory d/a/b/c whereas uutils creates the directory d/c
  2. also, the verbose options seems to be not working in uutils
@sylvestre sylvestre changed the title cp: recursive copy cp-parents.sh: cp: recursive copy Mar 29, 2022
@sylvestre sylvestre mentioned this issue Mar 29, 2022
10 tasks
@jfinkels
Copy link
Collaborator

jfinkels commented Apr 1, 2022

Note: The directories a/b/c and d must all exist before running those test cases

@ghost
Copy link
Author

ghost commented Apr 1, 2022

Note: The directories a/b/c and d must all exist before running those test cases

No. They get created.

@ghost ghost closed this as completed Apr 1, 2022
@ghost ghost reopened this Apr 1, 2022
@jfinkels
Copy link
Collaborator

jfinkels commented Apr 4, 2022

Hmm, with cp v 8.30, I see the following behavior.

If d does not exist:

$ cp --verbose -a --parents a/b/c d
cp: with --parents, the destination must be a directory
Try 'cp --help' for more information.

If d does exist but a/b/c does not exist:

$ cp --verbose -a --parents a/b/c d
cp: failed to get attributes of 'a': No such file or directory

If both a/b/c and d exist:

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

Do you see something different from that?

@jfinkels
Copy link
Collaborator

@DevSabb what do you think?

@ghost
Copy link
Author

ghost commented Jun 30, 2022

@jfinkels yes. I see similar behavior.

@niyaznigmatullin
Copy link
Contributor

I've checked now and it seems that uutils has the same behavior as GNU, but --verbose messages are not full. It prints the last file copied, but doesn't print anything for directories created. Seems like a good first issue from my point of view.

I also added test above and the same one with the symlink as the directory in PR #3721

@jfinkels
Copy link
Collaborator

jfinkels commented Sep 2, 2022

I've checked now and it seems that uutils has the same behavior as GNU, but --verbose messages are not full.

I don't see this. I still see the error (and also the verbose messages are absent).

$ mkdir -p a/b/c d
$ ./target/debug/cp -a --verbose --parents a/b/c d
$ ls -l d
total 4
drwxrwxr-x 2 jeffrey jeffrey 4096 Sep  1 20:31 c

Do you see something different from that?

@niyaznigmatullin
Copy link
Contributor

niyaznigmatullin commented Sep 2, 2022

I see the same.
It seems that I didn't look at the cp-parents.sh file then. What I tested was:

$ mkdir -p a/b d
$ touch a/b/c
$ ./target/debug/cp -a --verbose --parents a/b/c d
'a/b/c' -> 'd/a/b/c'
$ find d
d
d/a
d/a/b
d/a/b/c

@jfinkels
Copy link
Collaborator

jfinkels commented Sep 3, 2022

Ah, I see. There are different code paths if c is a file or if c is a directory.

jfinkels added a commit to jfinkels/coreutils that referenced this issue Sep 3, 2022
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 uutils#3332.
jfinkels added a commit to jfinkels/coreutils that referenced this issue Sep 3, 2022
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 uutils#3332.
sylvestre pushed a commit to jfinkels/coreutils that referenced this issue Sep 5, 2022
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 uutils#3332.
jfinkels added a commit to jfinkels/coreutils that referenced this issue Sep 5, 2022
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 uutils#3332.
sylvestre pushed a commit to jfinkels/coreutils that referenced this issue Sep 21, 2022
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 uutils#3332.
sylvestre pushed a commit to jfinkels/coreutils that referenced this issue Oct 5, 2022
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 uutils#3332.
jfinkels added a commit to jfinkels/coreutils that referenced this issue Oct 10, 2022
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 uutils#3332.
jfinkels added a commit to jfinkels/coreutils that referenced this issue Oct 10, 2022
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 uutils#3332.
jfinkels added a commit to jfinkels/coreutils that referenced this issue Oct 10, 2022
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 uutils#3332.
jfinkels added a commit to jfinkels/coreutils that referenced this issue Oct 11, 2022
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 uutils#3332.
Repository owner moved this from Todo to Done in GNU Compatibility Oct 23, 2022
@jfinkels
Copy link
Collaborator

The pull request #4071 resolved the issue

note that gnu creates the directory d/a/b/c whereas uutils creates the directory d/c

but it did not resolve the issue

also, the verbose options seems to be not working in uutils

so let's keep this open? Could also open a new issue if people prefer.

@jfinkels jfinkels reopened this Oct 23, 2022
jfinkels added a commit to jfinkels/coreutils that referenced this issue Nov 27, 2022
This commit corrects the behavior of `cp --parents --verbose` when the
source path is a file so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b d
    $ touch a/b/c
    $ cp --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'

Fixes uutils#3332.
jfinkels added a commit to jfinkels/coreutils that referenced this issue Nov 27, 2022
This commit corrects the behavior of `cp --parents --verbose` when the
source path is a file so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b d
    $ touch a/b/c
    $ cp --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'

Fixes uutils#3332.
sylvestre pushed a commit to jfinkels/coreutils that referenced this issue Nov 29, 2022
This commit corrects the behavior of `cp --parents --verbose` when the
source path is a file so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b d
    $ touch a/b/c
    $ cp --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'

Fixes uutils#3332.
jfinkels added a commit to jfinkels/coreutils that referenced this issue Dec 2, 2022
This commit corrects the behavior of `cp --parents --verbose` when the
source path is a file so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b d
    $ touch a/b/c
    $ cp --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'

Fixes uutils#3332.
sylvestre pushed a commit to jfinkels/coreutils that referenced this issue Dec 2, 2022
This commit corrects the behavior of `cp --parents --verbose` when the
source path is a file so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b d
    $ touch a/b/c
    $ cp --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'

Fixes uutils#3332.
jfinkels added a commit to jfinkels/coreutils that referenced this issue Dec 3, 2022
This commit corrects the behavior of `cp --parents --verbose` when the
source path is a file so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b d
    $ touch a/b/c
    $ cp --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'

Fixes uutils#3332.
jfinkels added a commit to jfinkels/coreutils that referenced this issue Dec 6, 2022
This commit corrects the behavior of `cp --parents --verbose` when the
source path is a file so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b d
    $ touch a/b/c
    $ cp --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'

Fixes uutils#3332.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
2 participants