From e60582f83800498b4bae6a9f554f12ed834dd73e Mon Sep 17 00:00:00 2001 From: wuyangfan <1102042793@qq.com> Date: Sun, 17 May 2026 04:46:44 +0800 Subject: [PATCH 1/3] docs: clarify that -e/--extension matches all entry types Short help stays minimal; long help and man page explain that extension filtering applies to directories as well unless --type restricts results. Addresses maintainer feedback on #1922. Fixes #1693 Co-authored-by: Cursor --- README.md | 2 +- doc/fd.1 | 10 ++++++---- src/cli.rs | 11 ++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 18a56d529..a4e6a41bf 100644 --- a/README.md +++ b/README.md @@ -328,7 +328,7 @@ Options: -t, --type Filter by type: file (f), directory (d/dir), symlink (l), executable (x), empty (e), socket (s), pipe (p), char-device (c), block-device (b) - -e, --extension Filter by file extension + -e, --extension Filter by extension -S, --size Limit results based on the size of files --changed-within Filter by file modification time (newer than) --changed-before Filter by file modification time (older than) diff --git a/doc/fd.1 b/doc/fd.1 index aa167b89f..3ba15e721 100644 --- a/doc/fd.1 +++ b/doc/fd.1 @@ -136,10 +136,10 @@ By default, fd does not descend into symlinked directories. Using this flag, sym also traversed. The flag can be overridden with '--no-follow'. .TP .B \-p, \-\-full\-path -By default, the search pattern is only matched against the filename (or directory name). Using +By default, the search pattern is only matched against the last path component (file or directory name). Using this flag, the .I pattern -is matched against the full path. +is matched against the absolute path. .TP .B \-0, \-\-print0 Separate search results by the null character (instead of newlines). Useful for piping results to @@ -250,9 +250,11 @@ Examples: .RE .TP .BI "\-e, \-\-extension " ext -Filter search results by file extension +Filter search results by extension .IR ext . -This option can be used repeatedly to allow for multiple possible file extensions. +By default, this applies to all entry types. Use \fB\-\-type\fR to restrict +the search to specific types. +This option can be used repeatedly to allow for multiple possible extensions. If you want to search for files without extension, you can use the regex '^[^.]+$' as a normal search pattern. diff --git a/src/cli.rs b/src/cli.rs index 9c54d7c2c..03a6e6c00 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -239,12 +239,12 @@ pub struct Opts { #[arg(long, overrides_with = "follow", hide = true, action = ArgAction::SetTrue)] no_follow: (), - /// By default, the search pattern is only matched against the filename (or directory name). Using this flag, the pattern is matched against the full (absolute) path. Example: + /// By default, the search pattern is only matched against the last path component (file or directory name). Using this flag, the pattern is matched against the absolute path. Example: /// fd --glob -p '**/.git/config' #[arg( long, short = 'p', - help = "Search full abs. path (default: filename only)", + help = "Search absolute path (default: last path component only)", long_help, verbatim_doc_comment )] @@ -364,8 +364,9 @@ pub struct Opts { )] pub filetype: Option>, - /// (Additionally) filter search results by their file extension. Multiple - /// allowable file extensions can be specified. + /// Filter results by extension. By default, this matches all entry types + /// (including directories whose names end with the extension). Use `--type` + /// to restrict the search to specific types. Multiple extensions can be specified. /// /// If you want to search for files without extension, /// you can use the regex '^[^.]+$' as a normal search pattern. @@ -373,7 +374,7 @@ pub struct Opts { long = "extension", short = 'e', value_name = "ext", - help = "Filter by file extension", + help = "Filter by extension", long_help )] pub extensions: Option>, From 9f938bea1ed30dcd3385bcb2e1f231df017650ae Mon Sep 17 00:00:00 2001 From: wuyangfan <1102042793@qq.com> Date: Sun, 17 May 2026 05:37:07 +0800 Subject: [PATCH 2/3] docs: drop accidental --full-path edits from extension PR Scope this branch to -e/--extension only (#1693). Full-path help clarifications remain in #1997. Co-authored-by: Cursor --- doc/fd.1 | 4 ++-- src/cli.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/fd.1 b/doc/fd.1 index 3ba15e721..be144fe8e 100644 --- a/doc/fd.1 +++ b/doc/fd.1 @@ -136,10 +136,10 @@ By default, fd does not descend into symlinked directories. Using this flag, sym also traversed. The flag can be overridden with '--no-follow'. .TP .B \-p, \-\-full\-path -By default, the search pattern is only matched against the last path component (file or directory name). Using +By default, the search pattern is only matched against the filename (or directory name). Using this flag, the .I pattern -is matched against the absolute path. +is matched against the full path. .TP .B \-0, \-\-print0 Separate search results by the null character (instead of newlines). Useful for piping results to diff --git a/src/cli.rs b/src/cli.rs index 03a6e6c00..184e75f29 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -239,12 +239,12 @@ pub struct Opts { #[arg(long, overrides_with = "follow", hide = true, action = ArgAction::SetTrue)] no_follow: (), - /// By default, the search pattern is only matched against the last path component (file or directory name). Using this flag, the pattern is matched against the absolute path. Example: + /// By default, the search pattern is only matched against the filename (or directory name). Using this flag, the pattern is matched against the full (absolute) path. Example: /// fd --glob -p '**/.git/config' #[arg( long, short = 'p', - help = "Search absolute path (default: last path component only)", + help = "Search full abs. path (default: filename only)", long_help, verbatim_doc_comment )] From 1161471b7e28c2bcebca55064efd07464cc5cdc8 Mon Sep 17 00:00:00 2001 From: wuyangfan Date: Wed, 17 Jun 2026 10:56:33 +0800 Subject: [PATCH 3/3] docs: clarify extension filter scope --- doc/fd.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/fd.1 b/doc/fd.1 index be144fe8e..078b42d79 100644 --- a/doc/fd.1 +++ b/doc/fd.1 @@ -252,9 +252,9 @@ Examples: .BI "\-e, \-\-extension " ext Filter search results by extension .IR ext . -By default, this applies to all entry types. Use \fB\-\-type\fR to restrict -the search to specific types. This option can be used repeatedly to allow for multiple possible extensions. +By default, extension filters apply to both files and directories. Use +\fB\-\-type\fR to restrict the search to specific types. If you want to search for files without extension, you can use the regex '^[^.]+$' as a normal search pattern.