coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

cp-parents.sh: cp: recursive copy

Open DevSabb opened this issue 3 years ago • 9 comments

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

DevSabb avatar Mar 29 '22 17:03 DevSabb

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

jfinkels avatar Apr 01 '22 01:04 jfinkels

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

No. They get created.

ghost avatar Apr 01 '22 14:04 ghost

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 avatar Apr 04 '22 02:04 jfinkels

@DevSabb what do you think?

jfinkels avatar May 21 '22 22:05 jfinkels

@jfinkels yes. I see similar behavior.

ghost avatar Jun 30 '22 17:06 ghost

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

niyaznigmatullin avatar Jul 17 '22 20:07 niyaznigmatullin

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?

jfinkels avatar Sep 02 '22 00:09 jfinkels

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

niyaznigmatullin avatar Sep 02 '22 05:09 niyaznigmatullin

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

jfinkels avatar Sep 03 '22 02:09 jfinkels

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 avatar Oct 23 '22 14:10 jfinkels