Make symlinks report their target's size, if valid #1070
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The size that exa lists for symlinks is currently equal to the size of the link itself (roughly, the number of characters in the name of the target), rather than the size of the target. This is consistent with
ls -l
, but is not particularly useful. The symlink's own size is necessarily quite small, and is self-evident if the target path is printed. On the other hand, displaying the size of the target could be useful, for example when comparing sizes of files in a symlink-based file store1.This PR sets the size of a symlink to be the size of its target, as long as the symlink points to an existing, non-cyclic location. I can't think of a use case where showing the symlink's own size is relevant, so in the interest of keeping the code simple, this PR does not add any flags; the new behaviour always applies.
Partially addresses #393.
Footnotes
It's certainly much easier than typing
stat -c'%s' $(realpath foo) $(realpath bar) $(realpath baz)
, especially since target file names aren't meaningful in my file store. ↩