mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-29 07:03:54 +00:00
Special-case the root directory when linking to it
It’s the only file where its path is the same as its file name, and has been the source of numerous bugs in the past… this special-case isn’t very clean, but it works.
This commit is contained in:
parent
f8b82642a6
commit
956aa85b3b
@ -47,7 +47,11 @@ pub fn filename(file: &File, colours: &Colours, links: bool, classify: bool) ->
|
||||
bits.push(colours.punctuation.paint("->"));
|
||||
bits.push(Style::default().paint(" "));
|
||||
|
||||
if let Some(parent) = target.path.parent() {
|
||||
if target.path.as_os_str() == "/" {
|
||||
// Do nothing when linking to the root directory.
|
||||
// The entirety of the path is the file name!
|
||||
}
|
||||
else if let Some(parent) = target.path.parent() {
|
||||
let coconut = parent.components().count();
|
||||
|
||||
if coconut == 1 && parent.has_root() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
[36mbroken[0m [31m->[0m [4;31m/testcases/links/nowhere[0m
|
||||
[36mforbidden[0m [31m->[0m [4;31m/proc/1/root[0m
|
||||
[36mroot[0m [38;5;244m->[0m [36m/[0m
|
||||
[36mroot[0m [38;5;244m->[0m [1;34m/[0m
|
||||
[36musr[0m [38;5;244m->[0m [36m/[1;34musr[0m
|
||||
|
@ -3,5 +3,5 @@
|
||||
[38;5;244m│ └──[0m [31m<No such file or directory (os error 2)>[0m
|
||||
[38;5;244m├──[0m [36mforbidden[0m [31m->[0m [4;31m/proc/1/root[0m
|
||||
[38;5;244m│ └──[0m [31m<Permission denied (os error 13)>[0m
|
||||
[38;5;244m├──[0m [36mroot[0m [38;5;244m->[0m [36m/[0m
|
||||
[38;5;244m├──[0m [36mroot[0m [38;5;244m->[0m [1;34m/[0m
|
||||
[38;5;244m└──[0m [36musr[0m [38;5;244m->[0m [36m/[1;34musr[0m
|
||||
|
Loading…
Reference in New Issue
Block a user