Skip to content

cp: should report file removal when replacing symlink by hardlink to same source #6530

@BenWiederhake

Description

@BenWiederhake

When doing cp -vl --remove-destination regularfile existing_symlink_to_regularfile, cp should report that it removes the destination file (because it needs to make space in order to create the new hardlink).

$ rm -f symlink; ln -s README.md symlink; ls -1i README.md symlink; cp -vl --remove-destination README.md symlink; ls -1i README.md symlink
20092600 README.md
20074037 symlink
removed 'symlink'
'README.md' -> 'symlink'
20092600 README.md
20092600 symlink
$ rm -f symlink; ln -s README.md symlink; ls -1i README.md symlink; cargo run -q cp -vl --remove-destination README.md symlink; ls -1i README.md symlink
20092600 README.md
20074037 symlink
'README.md' -> 'symlink'
20092600 README.md
20092600 symlink

Found while reading #6496, but only remotely related.

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