Skip to content

Commit a4ed987

Browse files
committed
added absolute path for symlink destination
1 parent 29aab5c commit a4ed987

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "natls"
3-
version = "1.2.4"
3+
version = "1.2.5"
44
authors = ["Will Lane <[email protected]>"]
55
description = "nat - the 'ls' replacement you never knew you needed"
66
license = "MIT"

src/main.rs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,33 @@ pub fn show_file_name(e: &&std::path::PathBuf, wide_mode: bool) -> Result<(), Bo
283283
print!("{}", color::Fg(color::LightMagenta));
284284
}
285285
print!("{} -> ", Style::new().bold().paint(e.file_name().unwrap().to_str().unwrap()));
286-
if fs::read_link(e)?.is_dir() {
287-
if !colors_on {
288-
print!("{}", color::Fg(color::LightBlue));
286+
match fs::canonicalize(fs::read_link(e)?) {
287+
Ok(_n) => {
288+
if fs::read_link(e)?.is_dir() {
289+
if !colors_on {
290+
print!("{}", color::Fg(color::LightBlue));
291+
print!("{}/", fs::canonicalize(fs::read_link(e)?).unwrap().to_str().unwrap())
292+
}
293+
} else {
294+
if !colors_on {
295+
print!("{}", color::Fg(color::LightGreen));
296+
print!("{}", fs::canonicalize(fs::read_link(e)?).unwrap().to_str().unwrap())
297+
}
298+
}
299+
},
300+
Err(_err) => {
301+
if fs::read_link(e)?.is_dir() {
302+
if !colors_on {
303+
print!("{}", color::Fg(color::LightBlue));
304+
print!("{}/", fs::read_link(e)?.file_name().unwrap().to_str().unwrap())
305+
}
306+
} else {
307+
if !colors_on {
308+
print!("{}", color::Fg(color::LightGreen));
309+
print!("{}", fs::read_link(e)?.file_name().unwrap().to_str().unwrap())
310+
}
311+
}
289312
}
290-
print!("{}/", fs::read_link(e)?.file_name().unwrap().to_str().unwrap());
291-
} else {
292-
if !colors_on {
293-
print!("{}", color::Fg(color::LightGreen));
294-
}
295-
print!("{}", fs::read_link(e)?.file_name().unwrap().to_str().unwrap());
296313
}
297314
if !wide_mode {
298315
print!("\n");

0 commit comments

Comments
 (0)