[BUG] `fd -e <ext>` extension search matches `foo.<ext>` in directory names
Checks
- [x] I have read the troubleshooting section and still think this is a bug.
Describe the bug you encountered:
Given the description of the -e option I think it could be reasonable to expect only matching files with a given extension, instead directories with .<ext> suffix are also matched e.g.
~/temp/bar » fd -e b
a.b/
An example of where those kinds of directory names can be found would be package names in some langs e.g. clojure.zip.
Describe what you expected to happen:
No response
What version of fd are you using?
fd 10.2.0
Which operating system / distribution are you on?
Darwin 21.5.0 x86_64
I don't think we can change the behaviour here, so at most this is a documentation issue. Where do you think the documentation should be clarified?
I think it would clutter the documentation a lot to change every mention of "files" to "files or directories". The UNIX convention is that directories are a kind of file. Perhaps we can mention this once somewhere?
+1 for not changing behavior because everything is a file
-e, --extension
Filter by file extension
should be something like
-e, --extension
Filter by extension (by default with all types)
Another reason is we shouldn't treat dir specially without --type parameter.
Opened https://github.com/sharkdp/fd/pull/ — documents that -e matches all entry types; use --type file to limit to files.
Doc clarification addressing maintainer feedback on #1922: #2001 (CI green, extension-only scope).
@Ra2-IFV Thanks — #2001 is doc-only (no behavior change): clarifies that -e applies to all entry types and points to --type for restricting to files. Matches your +1 on not treating dir specially by default.
Great minds think alike...... lol it's just about being UNIX
I would also appreciate it if someone could add separator support for -e
https://github.com/sharkdp/fd/blob/7f1b1471d5e3f88087eaad77885dc70968750bb3/src/main.rs#L343-L355