diff --git a/doc/fd.1 b/doc/fd.1 index 598ae27..2c50a1e 100644 --- a/doc/fd.1 +++ b/doc/fd.1 @@ -145,6 +145,9 @@ This option can be used repeatedly to allow for multiple file types. Filter search results by file extension .IR ext . This option can be used repeatedly to allow for multiple possible file extensions. + +If you want to search for files without extension, you can use the regex '^[^.]+$' +as a normal search pattern. .TP .BI "\-E, \-\-exclude " pattern Exclude files/directories that match the given glob pattern. diff --git a/src/app.rs b/src/app.rs index d759add..8c44ec6 100644 --- a/src/app.rs +++ b/src/app.rs @@ -279,7 +279,9 @@ pub fn build_app() -> App<'static, 'static> { .help("Filter by file extension") .long_help( "(Additionally) filter search results by their file extension. Multiple \ - allowable file extensions can be specified.", + allowable file extensions can be specified.\n\ + If you want to search for files without extension, \ + you can use the regex '^[^.]+$' as a normal search pattern.", ), ) .arg( diff --git a/tests/tests.rs b/tests/tests.rs index 616189e..e67eb5b 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1016,6 +1016,34 @@ fn test_extension() { te4.assert_output(&["--hidden", "--extension", ".hidden"], "test.hidden"); } +/// No file extension (test for the pattern provided in the --help text) +#[test] +fn test_no_extension() { + let te = TestEnv::new( + DEFAULT_DIRS, + &["a.foo", "aa", "one/b.foo", "one/bb", "one/two/three/d"], + ); + + te.assert_output( + &["^[^.]+$"], + "aa + one + one/bb + one/two + one/two/three + one/two/three/d + one/two/three/directory_foo + symlink", + ); + + te.assert_output( + &["^[^.]+$", "--type", "file"], + "aa + one/bb + one/two/three/d", + ); +} + /// Symlink as search directory #[test] fn test_symlink_as_root() {