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: should report file removal when replacing symlink by hardlink to same source #6530

Open
BenWiederhake opened this issue Jul 3, 2024 · 1 comment
Labels

Comments

@BenWiederhake
Copy link
Collaborator

BenWiederhake commented Jul 3, 2024

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.

@BenWiederhake
Copy link
Collaborator Author

Very similar scenario, probably the same bug, but perhaps not:

$ mkdir a; ln -s README.md a/symlink; ln -s README.md symlink # setup
$ cp -vP a/symlink . # Overwrites ./symlink
removed './symlink'
'a/symlink' -> './symlink'
$ cargo run -q cp -vP a/symlink . # Also overwrites ./symlink, but doesn't report removal
'a/symlink' -> './symlink'

Found while reading #6586.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant