make ls -lf outputs full path in symbolic target (#13605)

# Description
Fixes: #13479 

# User-Facing Changes
Given the following setup:
```
cd /tmp
touch src_file.txt
ln -s src_file.txt link1
```
### Before 
```
ls -lf link1 | get target.0  # It outputs src_file.txt
```
### After
```
ls -lf link1 | get target.0  # It outputs /tmp/src_file.txt
```
# Tests + Formatting
Added a test for the change
This commit is contained in:
Wind
2024-08-13 19:34:10 +08:00
committed by GitHub
parent 48e401834d
commit a55d172e52
2 changed files with 45 additions and 2 deletions

View File

@ -808,3 +808,28 @@ fn list_inside_tilde_glob_metachars_dir() {
},
);
}
#[test]
fn list_symlink_with_full_path() {
Playground::setup("list_symlink_with_full_path", |dirs, sandbox| {
sandbox.with_files(&[EmptyFile("test_file.txt")]);
#[cfg(unix)]
let _ = std::os::unix::fs::symlink("test_file.txt", dirs.test().join("test_link1"));
#[cfg(windows)]
let _ = std::os::windows::fs::symlink_file("test_file.txt", dirs.test().join("test_link1"));
let actual = nu!(
cwd: dirs.test(),
"ls -l test_link1 | get target.0"
);
assert_eq!(actual.out, "test_file.txt");
let actual = nu!(
cwd: dirs.test(),
"ls -lf test_link1 | get target.0"
);
assert_eq!(
actual.out,
dirs.test().join("test_file.txt").to_string_lossy()
);
})
}