Skip to content

list: show symlink targets (for tar and zip)#934

Open
tommady wants to merge 9 commits intoouch-org:mainfrom
tommady:close-issue-932
Open

list: show symlink targets (for tar and zip)#934
tommady wants to merge 9 commits intoouch-org:mainfrom
tommady:close-issue-932

Conversation

@tommady
Copy link
Contributor

@tommady tommady commented Mar 5, 2026

close: #932

Signed-off-by: tommady <tommady@users.noreply.github.com>
Copy link
Member

@marcospb19 marcospb19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey sorry for the eager review but what if is_dir and symlink_target get collapsed into one field for an enum for file type.

Regular and Directory unit variants
Symlink tuple variant with PathBuf inside.

so you express in the type system that symlink_target can't be some while is_dir is true.

wdyt

@tommady
Copy link
Contributor Author

tommady commented Mar 6, 2026

Hey sorry for the eager review but what if is_dir and symlink_target get collapsed into one field for an enum for file type.

Regular and Directory unit variants Symlink tuple variant with PathBuf inside.

so you express in the type system that symlink_target can't be some while is_dir is true.

wdyt

No worries at all,
I appreciate the suggestion!

I agree this is a great idea.
Collapsing is_dir and symlink_target into a single enum would model the state much more clearly and lets the type system enforce that a symlink target can’t exist while the entry is a directory.

tommady added 2 commits March 6, 2026 03:52
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
@tommady tommady marked this pull request as ready for review March 6, 2026 05:27
@tommady
Copy link
Contributor Author

tommady commented Mar 6, 2026

Hey @marcospb19,

I added support for hard links in the tar archive as well. This goes slightly beyond the scope of the original issue, so feel free to let me know if you’d prefer to keep the change more minimal.

For now, I made hard links display the same way as symlinks because I wasn’t sure what the best visual distinction would be (I’m definitely not a UI/UX designer 🤪).

Whenever you have time, I’d appreciate a review.

Thanks!

src/list.rs Outdated
Comment on lines +74 to +76
let _ = writeln!(
out,
"{}{}{} -> {}{}{}",
Copy link
Member

@marcospb19 marcospb19 Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if for hardlink we do:

A -> B (hardlink)

instead of

A -> B

To be explicit, I can't think of symbols that could replace the " (hardlink)" suffix

Copy link
Contributor Author

@tommady tommady Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we display hard links with =>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not the best idea since only me and you would be able to tell that -> means symlink and => means hardlink.

specially assuming the user will see one or the other, usually, and not both, so they'll just assume it's a symlink I believe

Copy link
Contributor Author

@tommady tommady Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since tar itself uses link to to represent hard links:

tar -tvf example.tar
drwxr-xr-x 1000/1000         0 2026-03-06 05:17 example
-rw-r--r-- 1000/1000         0 2026-03-05 08:42 example/hard_link
h--------- 0/0               0 1970-01-01 00:00 example/file link to example/hard_link

maybe we could just stick with the same wording.
WDYT?

Copy link
Member

@marcospb19 marcospb19 Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still prefer the -> symbol for symlinks and -> + (hardlink) :v sorry

Similar to what tree -a does in the CLI (the one I always download from pacman).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roger that~

src/list.rs Outdated
FileType::Symlink { target } | FileType::Hardlink { target } => {
if is_running_in_accessible_mode() {
// Accessible mode: use "->" for screen readers
let _ = writeln!(out, "{} -> {}", name, target.display());
Copy link
Member

@marcospb19 marcospb19 Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we added ->, now ouch list can't be used in scripts to provide a file list 🤔 .

Can you add a check for, when --quiet is set but --tree isn't, we don't print out the arrow nor the target? This way you can still ouch list -q | xargs rm -i even if there is a symlink in it.

Let me know if you think there is a better and simpler approach, to allow for -> but keeping this compatible with scripts.

Signed-off-by: tommady <tommady@users.noreply.github.com>
@marcospb19 marcospb19 changed the title let tar and zip can print symlink target list: show symlink targets (for tar and zip) Mar 11, 2026
tommady added 5 commits March 12, 2026 02:48
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ouch list should show symlink targets for supported formats

2 participants