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

Incomplete file-type handling #511

Closed
mcint opened this issue Nov 23, 2019 · 6 comments · Fixed by #572
Closed

Incomplete file-type handling #511

mcint opened this issue Nov 23, 2019 · 6 comments · Fixed by #572

Comments

@mcint
Copy link

mcint commented Nov 23, 2019

I was looking for sockets, but noticed some other file types are missing as well.

From find:

     -type t
             True if the file is of the specified type.  Possible file types are as follows:

             b       block special
             c       character special
             d       directory
             f       regular file
             l       symbolic link
             p       FIFO
             s       socket

equivalently, via the Open Group sys/stat.h linked from Wikipedia

S_IFMT  Type of file.
  S_IFBLK   Block special.
  S_IFCHR   Character special.
  S_IFIFO   FIFO special.
  S_IFREG   Regular.
  S_IFDIR   Directory.
  S_IFLNK   Symbolic link.
  S_IFSOCK  Socket.

For reference, fd offers the following filetype filters currently, according to --help:

    -t, --type <filetype>...
            Filter the search by type (multiple allowable filetypes can be specified):
              'f' or 'file':         regular files
              'd' or 'directory':    directories
              'l' or 'symlink':      symbolic links
              'x' or 'executable':   executables
              'e' or 'empty':        empty files or directories
@sharkdp
Copy link
Owner

sharkdp commented Dec 4, 2019

Thank you for the feedback. The problem is that sockets, FIFOs, etc. are specific to Unix-like operating systems, whereas fd tries to be platform independent.

Sure, we could add OS-specific features, but that would complicate a lot of things (the code base, documentation, testing).

@tmccombs
Copy link
Collaborator

tmccombs commented Dec 5, 2019

I'm not sure if it would meet @mcint's needs, but what if there was a "special" type to match files that are not "normal", which would include sockets, fifos, character/block special files, etc. on unix, and any similar os-specific specail files on windows if there are any.

@sharkdp
Copy link
Owner

sharkdp commented Dec 23, 2019

The question is if this is really a 80% use case (or even a 99% use case) or if this is just a request to add these filetypes "for completeness".

So far, I've never found myself in the need to search for sockets or FIFOs - but obviously that doesn't mean that we should definitely not add this to fd.

@baodrate
Copy link

The question is if this is really a 80% use case (or even a 99% use case) or if this is just a request to add these filetypes "for completeness".

Not saying this to be demanding, but I personally needed this today. I was taring some stuff and realized tar format cannot archive socket (understandably). I wanted to figure out which files were causing that and assumed I could depend on fd (which, other than this issue, has been a complete godsend).

Of course I can't speak to how much usage this would actually get, but I would say that this is a non-existing feature I find harder to work around than other (in comparison to find) missing features.

Thank you for the feedback. The problem is that sockets, FIFOs, etc. are specific to Unix-like operating systems, whereas fd tries to be platform independent.

I definitely understand that tho (in the general, I personally value Unix-portability more than Windows-compatibility). I respect your decision either way.

@sharkdp
Copy link
Owner

sharkdp commented Apr 16, 2020

Fixed via #572

I decided to only implement socket and pipe for now. "block", "character" seem rarely useful. "door" is a legacy file type.

@sharkdp
Copy link
Owner

sharkdp commented Apr 16, 2020

This has now been released in fd v8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants