fd icon indicating copy to clipboard operation
fd copied to clipboard

[BUG] `fd -e <ext>` extension search matches `foo.<ext>` in directory names

Open qazwsxpawel opened this issue 1 year ago • 7 comments

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

qazwsxpawel avatar Mar 22 '25 09:03 qazwsxpawel

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?

tavianator avatar Mar 22 '25 16:03 tavianator

+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)

Ra2-IFV avatar Jan 17 '26 14:01 Ra2-IFV

Another reason is we shouldn't treat dir specially without --type parameter.

Ra2-IFV avatar Jan 17 '26 14:01 Ra2-IFV

Opened https://github.com/sharkdp/fd/pull/ — documents that -e matches all entry types; use --type file to limit to files.

wyf027 avatar May 16 '26 20:05 wyf027

Doc clarification addressing maintainer feedback on #1922: #2001 (CI green, extension-only scope).

wyf027 avatar May 16 '26 21:05 wyf027

@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.

wyf027 avatar May 16 '26 22:05 wyf027

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

Ra2-IFV avatar May 17 '26 02:05 Ra2-IFV