uutils / uutils/coreutils

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

Open
#6,530 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.