mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
ln: canonicalize the parent directory of dst, not dst
dst may or may not exist. In case it exists it might already be a symlink. In neither case we should try to canonicalize dst, only its parent directory. https://www.gnu.org/software/coreutils/manual/html_node/ln-invocation.html > Relative symbolic links are generated based on their canonicalized > **containing directory**, and canonicalized targets.
This commit is contained in:
parent
af8f47ea6a
commit
6c46d09397
2 changed files with 20 additions and 1 deletions
|
@ -562,3 +562,21 @@ fn test_symlink_no_deref_file() {
|
|||
fn test_relative_requires_symbolic() {
|
||||
new_ucmd!().args(&["-r", "foo", "bar"]).fails();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_relative_dst_already_symlink() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.touch("file1");
|
||||
at.symlink_file("file1", "file2");
|
||||
ucmd.arg("-srf").arg("file1").arg("file2").succeeds();
|
||||
at.is_symlink("file2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_relative_src_already_symlink() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.touch("file1");
|
||||
at.symlink_file("file1", "file2");
|
||||
ucmd.arg("-sr").arg("file2").arg("file3").succeeds();
|
||||
assert!(at.resolve_link("file3").ends_with("file1"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue