Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include valid symlinks with both --follow and --type symlink #940

Closed
wants to merge 1 commit into from

Conversation

tmccombs
Copy link
Collaborator

This changes it so that if you specify --type symlink then it will
check if each entry is a symlink even if we would otherwise follow it.

Fixes: #939

This changes it so that if you specify `--type symlink` then it will
check if each entry is a symlink even if we would otherwise follow it.

Fixes: sharkdp#939
(!self.files && entry_type.is_file())
|| (!self.directories && entry_type.is_dir())
|| (!self.symlinks && entry_type.is_symlink())
(!self.files && entry_type.is_file() && !is_symlink)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It might be better for this (and the following line) to be something like:

Suggested change
(!self.files && entry_type.is_file() && !is_symlink)
(!self.files && entry_type.is_file() && !(self.symlinks && is_symlink))

(maybe factoring that out self.symlinks && is_symlink into a variable?)

so that if you specify only --type file it doesn't include symlinks to directories and vice versa.

@tavianator
Copy link
Collaborator

I'm not sure we should change behaviour here. RIght now fd is consistent with find: find -L -type l also finds only broken symlinks.

@sharkdp
Copy link
Owner

sharkdp commented Jan 10, 2022

I also think we should stick with the current behavior and maintain compatibility to find. Related discussion: BurntSushi/ripgrep#1503 #357

@tmccombs
Copy link
Collaborator Author

I'm ok with that.

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.

Is fd -L -t l supposed to work?
3 participants