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

Is -tf -td -tl -ts -tp always true? #917

Closed
x-yuri opened this issue Dec 29, 2021 · 6 comments
Closed

Is -tf -td -tl -ts -tp always true? #917

x-yuri opened this issue Dec 29, 2021 · 6 comments
Labels

Comments

@x-yuri
Copy link

x-yuri commented Dec 29, 2021

What version of fd are you using?
fd 8.3.0

I'm trying to exclude sockets so that tar wouldn't complain. And pipes since I don't need them. Should I use -tf -td -tl?

@tmccombs
Copy link
Collaborator

I think that -tf -td alone would match everything, because it matches all files and all directories.

@x-yuri
Copy link
Author

x-yuri commented Jan 1, 2022

Actually no:

$ mkfifo p
$ touch a
$ ln -s ./a b
$ fd -tf
a
$ fd -tl
b
$ fd -tp
p

Here are the corresponding lines:

fd/src/filetypes.rs

Lines 32 to 36 in 52f2255

(!self.files && entry_type.is_file())
|| (!self.directories && entry_type.is_dir())
|| (!self.symlinks && entry_type.is_symlink())
|| (!self.sockets && filesystem::is_socket(*entry_type))
|| (!self.pipes && filesystem::is_pipe(*entry_type))

And the is_file description says:

Tests whether this file type represents a regular file. The result is mutually exclusive to the results of is_dir and is_symlink; only zero or one of these tests may pass.

Then the following lines suggest that the options in the title aren't true for every entry:

fd/src/filetypes.rs

Lines 43 to 47 in 52f2255

|| !(entry_type.is_file()
|| entry_type.is_dir()
|| entry_type.is_symlink()
|| filesystem::is_socket(*entry_type)
|| filesystem::is_pipe(*entry_type))

So, I guess zero or one of those should match. But if zero, what are the other possible cases?

@tmccombs
Copy link
Collaborator

But if zero, what are the other possible cases?

That depends on the operating system, and possibly filesystem. On linux I believe that would include character and block special devices. Probably other special file types as well.

@tavianator
Copy link
Collaborator

On Linux I think block and character devices are the only other file types. The BSDs and macOS have "whiteout" files. Solaris and its descendants have "door" and "event port" files.

@sharkdp
Copy link
Owner

sharkdp commented Jan 23, 2022

@x-yuri Can this be closed? Or do you think we could improve the documentation?

@x-yuri
Copy link
Author

x-yuri commented Jan 23, 2022

I think yes. UPD Noticed the part about the documentation. I'm not sure. It's up to you.

@x-yuri x-yuri closed this as completed Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants