1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

uucore/fs: use the latest resolution that did not fail

When we ignore failures resolving symbolic links we should keep the
latest resolution that did not fail, not the original path.
This commit is contained in:
Michael Debertol 2021-08-24 19:11:47 +02:00
parent 68c9bfa658
commit ea41cc0ff6
2 changed files with 52 additions and 18 deletions

View file

@ -139,3 +139,23 @@ fn test_realpath_logical_mode() {
.succeeds()
.stdout_contains("dir1\n");
}
#[test]
fn test_realpath_dangling() {
let (at, mut ucmd) = at_and_ucmd!();
at.symlink_file("nonexistent-file", "link");
ucmd.arg("link")
.succeeds()
.stdout_only(at.plus_as_string("nonexistent-file\n"));
}
#[test]
fn test_realpath_loop() {
let (at, mut ucmd) = at_and_ucmd!();
at.symlink_file("2", "1");
at.symlink_file("3", "2");
at.symlink_file("1", "3");
ucmd.arg("1")
.succeeds()
.stdout_only(at.plus_as_string("2\n"));
}