Skip to content

cp: -rT copies through a target that is a symlink to a directory #14992

Description

@abendrothj

With -T the target is meant to be the destination itself, but when it is a symlink to a directory, cp -rT copies the tree into the directory the link points at and exits 0. GNU refuses with "cannot overwrite non-directory 'dst' with directory 'src'".

mkdir -p src real; echo new > src/f; echo old > real/f; ln -s real dst
cp -rT src dst    # uutils: rc=0, real/f is now "new"; GNU: error, real/f untouched

A related case: cp -r src dst with dst a dangling symlink creates the directory it points at (on Linux it fails with "File exists" instead). GNU refuses that too.

Checked with uutils main at 2b85f6f and GNU 9.12 built from source.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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