-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: allow removing symbolic link loop destination #3972
Conversation
437e2f1
to
ccc3810
Compare
Nice! |
src/uu/cp/src/cp.rs
Outdated
// because if `path` is a symbolic link and there are too many | ||
// levels of symbolic link, then those methods will return false | ||
// or an OS error. | ||
std::fs::metadata(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not functionally the same as just using symlink_metadata
? Because if the path is not a link, they are the same and if it is a link, then symlink_metadata
should return Ok
in a superset of the cases of metadata
, right?
fn file_or_link_exists(path: &Path) -> bool {
path.symlink_metadata().is_ok()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might be right. I'll update it.
ccc3810
to
aad3202
Compare
Allow `cp --remove-destination` to remove a symbolic link loop (or a symbolic link that initiates a chain of too many symbolic links). Before this commit, if `loop` were a symbolic link to itself, then cp --remove-destination file loop would fail with an error message. After this commit, it succeeds. This matches the behaviotr of GNU cp.
aad3202
to
24630db
Compare
Congrats! The gnu test tests/misc/tee is no longer failing! |
cool: |
Allow
cp --remove-destination
to remove a symbolic link loop (or a symbolic link that initiates a chain of too many symbolic links). Before this commit, ifloop
were a symbolic link to itself, thenwould fail with an error message. After this commit, it succeeds. This matches the behaviotr of GNU cp.
This should make the GNU test suite file
tests/cp/dir-rm-dest.sh
pass.