Skip to content

cp --parents is broken when source is symlink #8330

@julian-klode

Description

@julian-klode

cp --parents should require the target to be a directory:

$ mkdir ja.utf-8
$ ln -s ja.utf-8/ ja
$ gnucp --reflink -dp --parents ja x
gnucp: with --parents, the destination must be a directory
Try 'gnucp --help' for more information.

But it doesn't:

$ cp --reflink -dp --parents ja x
$ ls -lh x
lrwxrwxrwx 1 jak jak 9 Jul 11 07:04 x@ -> ja.utf-8/

Oh no.

Instead it even fails if the parent directory exists:

$ rm -r x
$ mkdir x
$ cp --reflink -dp --parents ja x
cp: cannot create symlink 'x' to 'ja.utf-8': File exists (os error 17)

Expected behavior:

$ gnucp --reflink -dp --parents ja x
$ ls x
ja@

This all seems to work if the source is not a symlink.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions