cp: should report file removal when replacing symlink by hardlink to same source
Open
Nobody has claimed this yet.
U - cp
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the cp entry point and reproduce the reported command with a regular file and a symlink to that same source. Compare the output with GNU cp, focusing on --remove-destination and -v; done means the Rust implementation reports removal of the symlink before reporting creation of the hardlink.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100