exa
exa copied to clipboard
Fix #393: add flag to dereference links
Fixes: https://github.com/ogham/exa/issues/393
There is currently no equivalent to ls
's -L
/--dereference
flag. This is often undesirable, as it is rare that a user is interested in the details of the link itself. As such, the -X
/--dereference
flag has been added which implements this functionality. I have chosen -X
as -L
was already taken, and in my mind -X
was similar to "across", in the sense that you are traversing "across" the link. The similar -H
/--dereference-command-line
flag from ls
has also not been implemented in this PR, however it should be straightforward to add, and I may add it to this PR if I have some additional time or it is requested. I am more than happy to accommodate other suggestions, or change my implementation in any way that would be more acceptable to the maintainers.
Output without the -X
flag (identical to before this PR):
cargo run -- -l
drwxr-xr-x - root 23 Sep 14:39 dir
.rw-r--r-- 450 root 23 Sep 12:24 file.txt
lrwxrwxrwx 14 andrzej 27 Sep 14:17 symlink-loop-0 -> symlink-loop-1
lrwxrwxrwx 14 andrzej 27 Sep 14:17 symlink-loop-1 -> symlink-loop-0
lrwxrwxrwx 20 andrzej 23 Sep 12:26 symlink-to-another-file -> dir/another-file.txt
lrwxrwxrwx 3 andrzej 23 Sep 12:26 symlink-to-dir -> dir
lrwxrwxrwx 8 andrzej 23 Sep 12:23 symlink-to-file -> file.txt
lrwxrwxrwx 15 andrzej 27 Sep 14:15 symlink-to-symlink-to-file -> symlink-to-file
Output with the -X
flag (links are now dereferenced):
cargo run -- -lX
drwxr-xr-x - root 23 Sep 14:39 dir
.rw-r--r-- 450 root 23 Sep 12:24 file.txt
---------- - - - symlink-loop-0 -> symlink-loop-1
---------- - - - symlink-loop-1 -> symlink-loop-0
lrw-r--r-- 0 root 27 Sep 16:16 symlink-to-another-file -> dir/another-file.txt
lrwxr-xr-x - root 23 Sep 14:39 symlink-to-dir -> dir
lrw-r--r-- 450 root 23 Sep 12:24 symlink-to-file -> file.txt
lrw-r--r-- 450 root 23 Sep 12:24 symlink-to-symlink-to-file -> symlink-to-file
Output when using the analogous -L
flag within ls
:
ls -lL
ls: cannot access 'symlink-loop-0': Too many levels of symbolic links
ls: cannot access 'symlink-loop-1': Too many levels of symbolic links
total 20
drwxr-xr-x 2 root root 4096 Sep 23 14:39 dir
-rw-r--r-- 1 root root 450 Sep 23 12:24 file.txt
l????????? ? ? ? ? ? symlink-loop-0
l????????? ? ? ? ? ? symlink-loop-1
-rw-r--r-- 1 root root 0 Sep 27 16:16 symlink-to-another-file
drwxr-xr-x 2 root root 4096 Sep 23 14:39 symlink-to-dir
-rw-r--r-- 1 root root 450 Sep 23 12:24 symlink-to-file
-rw-r--r-- 1 root root 450 Sep 23 12:24 symlink-to-symlink-to-file
Updates? This seems like a good feature to bring it more in parity with ls
I too would find this useful. Anything blocking this (beyond the merge conflicts)?