mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
cp: -l don't fail if dest is hardlink to source
This commit is contained in:
parent
356023b055
commit
4946478409
2 changed files with 25 additions and 0 deletions
|
@ -531,6 +531,25 @@ fn test_cp_arg_link() {
|
|||
assert_eq!(at.metadata(TEST_HELLO_WORLD_SOURCE).st_nlink(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_cp_arg_link_with_dest_hardlink_to_source() {
|
||||
use std::os::linux::fs::MetadataExt;
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let file = "file";
|
||||
let hardlink = "hardlink";
|
||||
|
||||
at.touch(file);
|
||||
at.hard_link(file, hardlink);
|
||||
|
||||
ucmd.args(&["--link", file, hardlink]).succeeds();
|
||||
|
||||
assert_eq!(at.metadata(file).st_nlink(), 2);
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(hardlink));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cp_arg_symlink() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue