From cbc6ddeefc3410cb5fa2a64ee796e6aef93ea11c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 12 Jul 2022 12:01:54 -0400 Subject: [PATCH 01/24] Implement --type executable on Windows Fixes #1051. --- CHANGELOG.md | 1 + Cargo.lock | 12 ++++++++++++ Cargo.toml | 3 +++ src/filesystem.rs | 9 ++++++--- src/filetypes.rs | 2 +- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69d1dc0..4f3e49c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Features +- `--type executable`/`-t` now works on Windows, see #1051 and #1061 ## Bugfixes diff --git a/Cargo.lock b/Cargo.lock index 03a483e..752446a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -176,6 +176,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "faccess" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ae66425802d6a903e268ae1a08b8c38ba143520f227a205edf4e9c7e3e26d5" +dependencies = [ + "bitflags", + "libc", + "winapi", +] + [[package]] name = "fd-find" version = "8.4.0" @@ -190,6 +201,7 @@ dependencies = [ "ctrlc", "diff", "dirs-next", + "faccess", "filetime", "globset", "humantime", diff --git a/Cargo.toml b/Cargo.toml index 1d4e4f4..848057f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,6 +63,9 @@ nix = { version = "0.24.2", default-features = false, features = ["signal"] } [target.'cfg(all(unix, not(target_os = "redox")))'.dependencies] libc = "0.2" +[target.'cfg(windows)'.dependencies] +faccess = "0.2.4" + # FIXME: Re-enable jemalloc on macOS # jemalloc is currently disabled on macOS due to a bug in jemalloc in combination with macOS # Catalina. See https://github.com/sharkdp/fd/issues/498 for details. diff --git a/src/filesystem.rs b/src/filesystem.rs index a025895..2e79591 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -7,6 +7,9 @@ use std::io; use std::os::unix::fs::{FileTypeExt, PermissionsExt}; use std::path::{Path, PathBuf}; +#[cfg(windows)] +use faccess::PathExt as _; + use normpath::PathExt; use crate::dir_entry; @@ -42,13 +45,13 @@ pub fn is_existing_directory(path: &Path) -> bool { } #[cfg(any(unix, target_os = "redox"))] -pub fn is_executable(md: &fs::Metadata) -> bool { +pub fn is_executable(_: &Path, md: &fs::Metadata) -> bool { md.permissions().mode() & 0o111 != 0 } #[cfg(windows)] -pub fn is_executable(_: &fs::Metadata) -> bool { - false +pub fn is_executable(path: &Path, _: &fs::Metadata) -> bool { + path.executable() } pub fn is_empty(entry: &dir_entry::DirEntry) -> bool { diff --git a/src/filetypes.rs b/src/filetypes.rs index 1209549..42e95d2 100644 --- a/src/filetypes.rs +++ b/src/filetypes.rs @@ -24,7 +24,7 @@ impl FileTypes { || (self.executables_only && !entry .metadata() - .map(filesystem::is_executable) + .map(|md| filesystem::is_executable(entry.path(), md)) .unwrap_or(false)) || (self.empty_only && !filesystem::is_empty(entry)) || !(entry_type.is_file() From c7370ca82c25f899f4e7528b3ec8b35bfdeb4ccc Mon Sep 17 00:00:00 2001 From: Marie Katrine Ekeberg Date: Sun, 11 Sep 2022 20:11:53 +0200 Subject: [PATCH 02/24] Simplistic "Command not found" error message --- Cargo.lock | 56 +++++++++------------------------------------ Cargo.toml | 2 +- src/exec/command.rs | 2 +- 3 files changed, 13 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 752446a..92927d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,13 +28,13 @@ checksum = "c91f1f46651137be86f3a2b9a8359f9ab421d04d941c62b5982e1ca21113adf9" [[package]] name = "argmax" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "932fb17af6e53a41ce7312f1ae1ba2a6f3f613fe36f38ad655b212906eb9657f" +checksum = "5b7e3ef5e3a7f2c5e5a49d90ad087c03d38258e75155daac64deb62c50972c66" dependencies = [ "lazy_static", "libc", - "nix 0.23.1", + "nix", ] [[package]] @@ -141,11 +141,11 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.2.3" +version = "3.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d91974fbbe88ec1df0c24a4f00f99583667a7e2e6272b2b92d294d81e462173" +checksum = "b37feaa84e6861e00a1f5e5aa8da3ee56d605c9992d33e082786754828e20865" dependencies = [ - "nix 0.25.0", + "nix", "winapi", ] @@ -209,7 +209,7 @@ dependencies = [ "jemallocator", "libc", "lscolors", - "nix 0.24.2", + "nix", "normpath", "num_cpus", "once_cell", @@ -353,9 +353,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.132" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "log" @@ -381,28 +381,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "nix" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" -dependencies = [ - "bitflags", - "cc", - "cfg-if", - "libc", - "memoffset", -] - [[package]] name = "nix" version = "0.24.2" @@ -414,18 +392,6 @@ dependencies = [ "libc", ] -[[package]] -name = "nix" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb" -dependencies = [ - "autocfg", - "bitflags", - "cfg-if", - "libc", -] - [[package]] name = "normpath" version = "0.3.2" @@ -466,9 +432,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" +checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" [[package]] name = "os_str_bytes" diff --git a/Cargo.toml b/Cargo.toml index 848057f..e06d97c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ version_check = "0.9" [dependencies] ansi_term = "0.12" -argmax = "0.3.0" +argmax = "0.3.1" atty = "0.2" ignore = "0.4.3" num_cpus = "1.13" diff --git a/src/exec/command.rs b/src/exec/command.rs index a642a40..590a294 100644 --- a/src/exec/command.rs +++ b/src/exec/command.rs @@ -96,7 +96,7 @@ pub fn execute_commands>>( pub fn handle_cmd_error(cmd: Option<&Command>, err: io::Error) -> ExitCode { match (cmd, err) { (Some(cmd), err) if err.kind() == io::ErrorKind::NotFound => { - print_error(format!("Command not found: {:?}", cmd)); + print_error(format!("Command not found: {:?}", cmd.get_program())); ExitCode::GeneralError } (_, err) => { From 90e860c7a591d6ed40b9392c2088a22f5d297ae6 Mon Sep 17 00:00:00 2001 From: Marie Katrine Ekeberg Date: Sun, 11 Sep 2022 20:29:41 +0200 Subject: [PATCH 03/24] Update msrv --- .github/workflows/CICD.yml | 2 +- README.md | 2 +- build.rs | 2 +- clippy.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index a0803ab..718fc19 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -1,7 +1,7 @@ name: CICD env: - MIN_SUPPORTED_RUST_VERSION: "1.56.0" + MIN_SUPPORTED_RUST_VERSION: "1.57.0" CICD_INTERMEDIATES_DIR: "_cicd-intermediates" on: diff --git a/README.md b/README.md index 7af5da6..9ca1a73 100644 --- a/README.md +++ b/README.md @@ -676,7 +676,7 @@ With Rust's package manager [cargo](https://github.com/rust-lang/cargo), you can ``` cargo install fd-find ``` -Note that rust version *1.56.0* or later is required. +Note that rust version *1.57.0* or later is required. `make` is also needed for the build. diff --git a/build.rs b/build.rs index d78641a..771f932 100644 --- a/build.rs +++ b/build.rs @@ -7,7 +7,7 @@ use Shell::*; include!("src/app.rs"); fn main() { - let min_version = "1.56"; + let min_version = "1.57"; match version_check::is_min_version(min_version) { Some(true) => {} diff --git a/clippy.toml b/clippy.toml index 0d369b5..23b32c1 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.56.0" +msrv = "1.57.0" From d6b1d16bfcfacf891db6aea10efff87a7ceab1ab Mon Sep 17 00:00:00 2001 From: Marie Katrine Ekeberg Date: Sun, 11 Sep 2022 20:39:04 +0200 Subject: [PATCH 04/24] Use to_string_lossy to avoid relying on Debug-outputs --- src/exec/command.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/exec/command.rs b/src/exec/command.rs index 590a294..ff13f91 100644 --- a/src/exec/command.rs +++ b/src/exec/command.rs @@ -96,7 +96,10 @@ pub fn execute_commands>>( pub fn handle_cmd_error(cmd: Option<&Command>, err: io::Error) -> ExitCode { match (cmd, err) { (Some(cmd), err) if err.kind() == io::ErrorKind::NotFound => { - print_error(format!("Command not found: {:?}", cmd.get_program())); + print_error(format!( + "Command not found: {}", + cmd.get_program().to_string_lossy() + )); ExitCode::GeneralError } (_, err) => { From c48586de08c678b506f74d5a394baf3a8d15256a Mon Sep 17 00:00:00 2001 From: David Peter Date: Sun, 11 Sep 2022 20:58:42 +0200 Subject: [PATCH 05/24] Add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f3e49c..fb75b58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ## Bugfixes - fd returns an error when current working directory does not exist while a search path is specified, see #1072 (@vijfhoek) +- Improved "command not found" error message, see #1083 and #1109 (@themkat) ## Changes From c127dc89a57d25e58c500167837843bb38bcd952 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Tue, 16 Aug 2022 19:16:51 -0700 Subject: [PATCH 06/24] Add a link back the Github page to address #1052 --- doc/fd.1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/fd.1 b/doc/fd.1 index 6144f73..f54a7ae 100644 --- a/doc/fd.1 +++ b/doc/fd.1 @@ -455,5 +455,7 @@ $ fd -e py .TP .RI "Open all search results with vim:" $ fd pattern -X vim +.SH BUGS +Bugs can be reported on the Github page: https://github.com/sharkdp/fd .SH SEE ALSO .BR find (1) From 97dfd8b428b150b1c41633835393c3e84101092c Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Wed, 17 Aug 2022 08:40:08 -0700 Subject: [PATCH 07/24] Simplify some wording --- doc/fd.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/fd.1 b/doc/fd.1 index f54a7ae..9247415 100644 --- a/doc/fd.1 +++ b/doc/fd.1 @@ -456,6 +456,6 @@ $ fd -e py .RI "Open all search results with vim:" $ fd pattern -X vim .SH BUGS -Bugs can be reported on the Github page: https://github.com/sharkdp/fd +Bugs can be reported on Github: https://github.com/sharkdp/fd .SH SEE ALSO .BR find (1) From fcf8099587e78e9eee6e7bcc741a1b16c747fbbc Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Wed, 17 Aug 2022 08:40:23 -0700 Subject: [PATCH 08/24] Add Github URL to `--help` also --- src/app.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index a9eba45..6a3f550 100644 --- a/src/app.rs +++ b/src/app.rs @@ -12,9 +12,9 @@ pub fn build_app() -> Command<'static> { .color(clap_color_choice) .setting(AppSettings::DeriveDisplayOrder) .dont_collapse_args_in_usage(true) - .after_help( - "Note: `fd -h` prints a short and concise overview while `fd --help` gives all \ - details.", + .after_help("Bugs can be reported on Github: https://github.com/sharkdp/fd\n +Note: `fd -h` prints a short and concise overview while `fd --help` gives all \ + details.", ) .arg( Arg::new("hidden") From cb91a5c848f1150c6e2e2dde3d6700d3e2ac4d72 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Wed, 17 Aug 2022 09:21:27 -0700 Subject: [PATCH 09/24] Simplify some whitespace on lines --- src/app.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index 6a3f550..45dd443 100644 --- a/src/app.rs +++ b/src/app.rs @@ -12,9 +12,8 @@ pub fn build_app() -> Command<'static> { .color(clap_color_choice) .setting(AppSettings::DeriveDisplayOrder) .dont_collapse_args_in_usage(true) - .after_help("Bugs can be reported on Github: https://github.com/sharkdp/fd\n -Note: `fd -h` prints a short and concise overview while `fd --help` gives all \ - details.", + .after_help("Bugs can be reported on Github: https://github.com/sharkdp/fd\n\n\ + Note: `fd -h` prints a short and concise overview while `fd --help` gives all details.", ) .arg( Arg::new("hidden") From 2569317ee876ae5be8fe8657114c9acb5f63af3e Mon Sep 17 00:00:00 2001 From: David Peter Date: Sun, 11 Sep 2022 21:02:37 +0200 Subject: [PATCH 10/24] Revert changes in help text, add /issues in manpage --- doc/fd.1 | 2 +- src/app.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/fd.1 b/doc/fd.1 index 9247415..6616ee9 100644 --- a/doc/fd.1 +++ b/doc/fd.1 @@ -456,6 +456,6 @@ $ fd -e py .RI "Open all search results with vim:" $ fd pattern -X vim .SH BUGS -Bugs can be reported on Github: https://github.com/sharkdp/fd +Bugs can be reported on GitHub: https://github.com/sharkdp/fd/issues .SH SEE ALSO .BR find (1) diff --git a/src/app.rs b/src/app.rs index 45dd443..a9eba45 100644 --- a/src/app.rs +++ b/src/app.rs @@ -12,8 +12,9 @@ pub fn build_app() -> Command<'static> { .color(clap_color_choice) .setting(AppSettings::DeriveDisplayOrder) .dont_collapse_args_in_usage(true) - .after_help("Bugs can be reported on Github: https://github.com/sharkdp/fd\n\n\ - Note: `fd -h` prints a short and concise overview while `fd --help` gives all details.", + .after_help( + "Note: `fd -h` prints a short and concise overview while `fd --help` gives all \ + details.", ) .arg( Arg::new("hidden") From bd44c82404fb88bd96e6c261cdeae11c38b93add Mon Sep 17 00:00:00 2001 From: David Peter Date: Sun, 11 Sep 2022 21:03:12 +0200 Subject: [PATCH 11/24] Add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb75b58..8f97ec0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ## Other +- Added link back to GitHub in man page, see #1086 (@scottchiefbaker) # v8.4.0 From f63c4634710af20d8d8d8f6eb8bbbd1466c97af1 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Wed, 31 Aug 2022 23:37:41 -0600 Subject: [PATCH 12/24] update dependencies --- Cargo.lock | 227 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 173 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 92927d7..4055e5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,13 +4,22 @@ version = 3 [[package]] name = "aho-corasick" -version = "0.7.18" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" dependencies = [ "memchr", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -22,9 +31,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.59" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91f1f46651137be86f3a2b9a8359f9ab421d04d941c62b5982e1ca21113adf9" +checksum = "b9a8f622bcf6ff3df478e9deba3e03e4e04b300f8e6a139e192c05fa3490afc7" [[package]] name = "argmax" @@ -34,7 +43,7 @@ checksum = "5b7e3ef5e3a7f2c5e5a49d90ad087c03d38258e75155daac64deb62c50972c66" dependencies = [ "lazy_static", "libc", - "nix", + "nix 0.24.2", ] [[package]] @@ -69,6 +78,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "bumpalo" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" + [[package]] name = "cc" version = "1.0.73" @@ -83,28 +98,30 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" dependencies = [ - "libc", + "iana-time-zone", + "js-sys", "num-integer", "num-traits", "time", + "wasm-bindgen", "winapi", ] [[package]] name = "clap" -version = "3.1.18" +version = "3.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" +checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd" dependencies = [ "atty", "bitflags", "clap_lex", "indexmap", - "lazy_static", + "once_cell", "strsim", "termcolor", "terminal_size", @@ -113,39 +130,45 @@ dependencies = [ [[package]] name = "clap_complete" -version = "3.1.4" +version = "3.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da92e6facd8d73c22745a5d3cbb59bdf8e46e3235c923e516527d8e81eec14a4" +checksum = "e4179da71abd56c26b54dd0c248cc081c1f43b0a1a7e8448e28e57a29baa993d" dependencies = [ "clap", ] [[package]] name = "clap_lex" -version = "0.2.0" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" dependencies = [ "os_str_bytes", ] [[package]] -name = "crossbeam-utils" -version = "0.8.8" +name = "core-foundation-sys" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "crossbeam-utils" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" dependencies = [ "cfg-if", - "lazy_static", + "once_cell", ] [[package]] name = "ctrlc" -version = "3.2.2" +version = "3.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b37feaa84e6861e00a1f5e5aa8da3ee56d605c9992d33e082786754828e20865" +checksum = "1d91974fbbe88ec1df0c24a4f00f99583667a7e2e6272b2b92d294d81e462173" dependencies = [ - "nix", + "nix 0.25.0", "winapi", ] @@ -209,7 +232,7 @@ dependencies = [ "jemallocator", "libc", "lscolors", - "nix", + "nix 0.24.2", "normpath", "num_cpus", "once_cell", @@ -253,13 +276,13 @@ checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "getrandom" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -277,9 +300,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hermit-abi" @@ -296,6 +319,20 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "iana-time-zone" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c495f162af0bf17656d0014a0eded5f3cd2f365fdd204548c2869db89359dc7" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "js-sys", + "once_cell", + "wasm-bindgen", + "winapi", +] + [[package]] name = "ignore" version = "0.4.18" @@ -316,9 +353,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.8.2" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", "hashbrown", @@ -326,9 +363,9 @@ dependencies = [ [[package]] name = "jemalloc-sys" -version = "0.5.0+5.3.0" +version = "0.5.1+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f655c3ecfa6b0d03634595b4b54551d4bd5ac208b9e0124873949a7ab168f70b" +checksum = "b7c2b313609b95939cb0c5a5c6917fb9b7c9394562aa3ef44eb66ffa51736432" dependencies = [ "cc", "fs_extra", @@ -345,6 +382,15 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -353,9 +399,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" [[package]] name = "log" @@ -392,6 +438,18 @@ dependencies = [ "libc", ] +[[package]] +name = "nix" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb" +dependencies = [ + "autocfg", + "bitflags", + "cfg-if", + "libc", +] + [[package]] name = "normpath" version = "0.3.2" @@ -438,9 +496,9 @@ checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" [[package]] name = "os_str_bytes" -version = "6.1.0" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" +checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" [[package]] name = "proc-macro-error" @@ -468,18 +526,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.39" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.18" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] @@ -523,9 +581,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] @@ -584,9 +642,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.95" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" dependencies = [ "proc-macro2", "quote", @@ -655,18 +713,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.31" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +checksum = "8c1b05ca9d106ba7d2e31a9dab4a64e7be2cce415321966ea3132c49a656e252" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.31" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +checksum = "e8f2591983642de85c921015f3f070c665a197ed69e417af436115e3a1407487" dependencies = [ "proc-macro2", "quote", @@ -684,19 +742,20 @@ dependencies = [ [[package]] name = "time" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ "libc", + "wasi 0.10.0+wasi-snapshot-preview1", "winapi", ] [[package]] name = "unicode-ident" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" +checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" [[package]] name = "users" @@ -727,9 +786,69 @@ dependencies = [ [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" [[package]] name = "winapi" From 9ea882d7cca53e15900cdba7f3a91126a6aa5475 Mon Sep 17 00:00:00 2001 From: David Peter Date: Sun, 11 Sep 2022 21:29:43 +0200 Subject: [PATCH 13/24] Fix clippy suggestions --- src/exec/mod.rs | 2 +- src/exec/token.rs | 2 +- src/exit_codes.rs | 2 +- src/filter/size.rs | 2 +- src/filter/time.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/exec/mod.rs b/src/exec/mod.rs index fc26da2..da83223 100644 --- a/src/exec/mod.rs +++ b/src/exec/mod.rs @@ -24,7 +24,7 @@ pub use self::job::{batch, job}; use self::token::Token; /// Execution mode of the command -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ExecutionMode { /// Command is executed for each search result OneByOne, diff --git a/src/exec/token.rs b/src/exec/token.rs index 0cf4df3..a295745 100644 --- a/src/exec/token.rs +++ b/src/exec/token.rs @@ -4,7 +4,7 @@ use std::fmt::{self, Display, Formatter}; /// /// Each `Token` contains either text, or a placeholder variant, which will be used to generate /// commands after all tokens for a given command template have been collected. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum Token { Placeholder, Basename, diff --git a/src/exit_codes.rs b/src/exit_codes.rs index e44111b..c87d8c2 100644 --- a/src/exit_codes.rs +++ b/src/exit_codes.rs @@ -3,7 +3,7 @@ use std::process; #[cfg(unix)] use nix::sys::signal::{raise, signal, SigHandler, Signal}; -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ExitCode { Success, HasResults(bool), diff --git a/src/filter/size.rs b/src/filter/size.rs index 2af20bc..d8ab4e8 100644 --- a/src/filter/size.rs +++ b/src/filter/size.rs @@ -4,7 +4,7 @@ use regex::Regex; static SIZE_CAPTURES: Lazy = Lazy::new(|| Regex::new(r"(?i)^([+-]?)(\d+)(b|[kmgt]i?b?)$").unwrap()); -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum SizeFilter { Max(u64), Min(u64), diff --git a/src/filter/time.rs b/src/filter/time.rs index eb43c4b..e854c39 100644 --- a/src/filter/time.rs +++ b/src/filter/time.rs @@ -3,7 +3,7 @@ use chrono::{offset::TimeZone, DateTime, Local, NaiveDate}; use std::time::SystemTime; /// Filter based on time ranges. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum TimeFilter { Before(SystemTime), After(SystemTime), From e46d402ed1a1bd1774a570f915bc3e8ddb5b5206 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 12 Jul 2022 12:09:36 -0400 Subject: [PATCH 14/24] Enable jemallocator on 64-bit musl builds Partial fix for #710 and #980. --- Cargo.toml | 2 +- src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e06d97c..f41e792 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ faccess = "0.2.4" # FIXME: Re-enable jemalloc on macOS # jemalloc is currently disabled on macOS due to a bug in jemalloc in combination with macOS # Catalina. See https://github.com/sharkdp/fd/issues/498 for details. -[target.'cfg(all(not(windows), not(target_os = "android"), not(target_os = "macos"), not(target_os = "freebsd"), not(target_env = "musl"), not(target_arch = "riscv64")))'.dependencies] +[target.'cfg(all(not(windows), not(target_os = "android"), not(target_os = "macos"), not(target_os = "freebsd"), not(all(target_env = "musl", target_pointer_width = "32")), not(target_arch = "riscv64")))'.dependencies] jemallocator = {version = "0.5.0", optional = true} [dev-dependencies] diff --git a/src/main.rs b/src/main.rs index 99aee3e..f204d31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ use crate::regex_helper::{pattern_has_uppercase_char, pattern_matches_strings_wi not(target_os = "android"), not(target_os = "macos"), not(target_os = "freebsd"), - not(target_env = "musl"), + not(all(target_env = "musl", target_pointer_width = "32")), not(target_arch = "riscv64"), feature = "use-jemalloc" ))] From 4419401b6c221f18eab98a58664ff2d75950a8be Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 21 Sep 2022 12:36:38 -0400 Subject: [PATCH 15/24] Enable --strip-cwd-prefix by default except with -0 Fixes #1046. --- src/app.rs | 6 +- src/main.rs | 2 +- tests/tests.rs | 666 ++++++++++++++++++++++++------------------------- 3 files changed, 331 insertions(+), 343 deletions(-) diff --git a/src/app.rs b/src/app.rs index a9eba45..5348ade 100644 --- a/src/app.rs +++ b/src/app.rs @@ -719,10 +719,10 @@ pub fn build_app() -> Command<'static> { .long("strip-cwd-prefix") .conflicts_with_all(&["path", "search-path"]) .hide_short_help(true) - .help("strip './' prefix from non-tty outputs") + .help("strip './' prefix from -0/--print0 output") .long_help( - "By default, relative paths are prefixed with './' when the output goes to a non \ - interactive terminal (TTY). Use this flag to disable this behaviour." + "By default, relative paths are prefixed with './' when -0/--print0 is given, to \ + make them safer for use with xargs. Use this flag to disable this behaviour." ) ); diff --git a/src/main.rs b/src/main.rs index f204d31..dba6d4b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -385,7 +385,7 @@ fn construct_config(matches: clap::ArgMatches, pattern_regex: &str) -> Result>(path: P, size_in_bytes: usize) { fn test_simple() { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); - te.assert_output(&["a.foo"], "./a.foo"); - te.assert_output(&["b.foo"], "./one/b.foo"); - te.assert_output(&["d.foo"], "./one/two/three/d.foo"); + te.assert_output(&["a.foo"], "a.foo"); + te.assert_output(&["b.foo"], "one/b.foo"); + te.assert_output(&["d.foo"], "one/two/three/d.foo"); te.assert_output( &["foo"], - "./a.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/d.foo - ./one/two/three/directory_foo/", + "a.foo + one/b.foo + one/two/c.foo + one/two/C.Foo2 + one/two/three/d.foo + one/two/three/directory_foo/", ); } @@ -80,17 +80,17 @@ fn test_simple() { #[test] fn test_empty_pattern() { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); - let expected = "./a.foo - ./e1 e2 - ./one/ - ./one/b.foo - ./one/two/ - ./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/ - ./one/two/three/d.foo - ./one/two/three/directory_foo/ - ./symlink"; + let expected = "a.foo + e1 e2 + one/ + one/b.foo + one/two/ + one/two/c.foo + one/two/C.Foo2 + one/two/three/ + one/two/three/d.foo + one/two/three/directory_foo/ + symlink"; te.assert_output(&["--regex"], expected); te.assert_output(&["--fixed-strings"], expected); @@ -209,17 +209,17 @@ fn test_regex_searches() { te.assert_output( &["[a-c].foo"], - "./a.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/C.Foo2", + "a.foo + one/b.foo + one/two/c.foo + one/two/C.Foo2", ); te.assert_output( &["--case-sensitive", "[a-c].foo"], - "./a.foo - ./one/b.foo - ./one/two/c.foo", + "a.foo + one/b.foo + one/two/c.foo", ); } @@ -230,21 +230,21 @@ fn test_smart_case() { te.assert_output( &["c.foo"], - "./one/two/c.foo - ./one/two/C.Foo2", + "one/two/c.foo + one/two/C.Foo2", ); - te.assert_output(&["C.Foo"], "./one/two/C.Foo2"); + te.assert_output(&["C.Foo"], "one/two/C.Foo2"); - te.assert_output(&["Foo"], "./one/two/C.Foo2"); + te.assert_output(&["Foo"], "one/two/C.Foo2"); // Only literal uppercase chars should trigger case sensitivity. te.assert_output( &["\\Ac"], - "./one/two/c.foo - ./one/two/C.Foo2", + "one/two/c.foo + one/two/C.Foo2", ); - te.assert_output(&["\\AC"], "./one/two/C.Foo2"); + te.assert_output(&["\\AC"], "one/two/C.Foo2"); } /// Case sensitivity (--case-sensitive) @@ -252,13 +252,13 @@ fn test_smart_case() { fn test_case_sensitive() { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); - te.assert_output(&["--case-sensitive", "c.foo"], "./one/two/c.foo"); + te.assert_output(&["--case-sensitive", "c.foo"], "one/two/c.foo"); - te.assert_output(&["--case-sensitive", "C.Foo"], "./one/two/C.Foo2"); + te.assert_output(&["--case-sensitive", "C.Foo"], "one/two/C.Foo2"); te.assert_output( &["--ignore-case", "--case-sensitive", "C.Foo"], - "./one/two/C.Foo2", + "one/two/C.Foo2", ); } @@ -269,14 +269,14 @@ fn test_case_insensitive() { te.assert_output( &["--ignore-case", "C.Foo"], - "./one/two/c.foo - ./one/two/C.Foo2", + "one/two/c.foo + one/two/C.Foo2", ); te.assert_output( &["--case-sensitive", "--ignore-case", "C.Foo"], - "./one/two/c.foo - ./one/two/C.Foo2", + "one/two/c.foo + one/two/C.Foo2", ); } @@ -287,25 +287,25 @@ fn test_glob_searches() { te.assert_output( &["--glob", "*.foo"], - "./a.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/three/d.foo", + "a.foo + one/b.foo + one/two/c.foo + one/two/three/d.foo", ); te.assert_output( &["--glob", "[a-c].foo"], - "./a.foo - ./one/b.foo - ./one/two/c.foo", + "a.foo + one/b.foo + one/two/c.foo", ); te.assert_output( &["--glob", "[a-c].foo*"], - "./a.foo - ./one/b.foo - ./one/two/C.Foo2 - ./one/two/c.foo", + "a.foo + one/b.foo + one/two/C.Foo2 + one/two/c.foo", ); } @@ -317,19 +317,19 @@ fn test_full_path_glob_searches() { te.assert_output( &["--glob", "--full-path", "**/one/**/*.foo"], - "./one/b.foo - ./one/two/c.foo - ./one/two/three/d.foo", + "one/b.foo + one/two/c.foo + one/two/three/d.foo", ); te.assert_output( &["--glob", "--full-path", "**/one/*/*.foo"], - " ./one/two/c.foo", + " one/two/c.foo", ); te.assert_output( &["--glob", "--full-path", "**/one/*/*/*.foo"], - " ./one/two/three/d.foo", + " one/two/three/d.foo", ); } @@ -339,11 +339,11 @@ fn test_smart_case_glob_searches() { te.assert_output( &["--glob", "c.foo*"], - "./one/two/C.Foo2 - ./one/two/c.foo", + "one/two/C.Foo2 + one/two/c.foo", ); - te.assert_output(&["--glob", "C.Foo*"], "./one/two/C.Foo2"); + te.assert_output(&["--glob", "C.Foo*"], "one/two/C.Foo2"); } /// Glob-based searches (--glob) in combination with --case-sensitive @@ -351,7 +351,7 @@ fn test_smart_case_glob_searches() { fn test_case_sensitive_glob_searches() { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); - te.assert_output(&["--glob", "--case-sensitive", "c.foo*"], "./one/two/c.foo"); + te.assert_output(&["--glob", "--case-sensitive", "c.foo*"], "one/two/c.foo"); } /// Glob-based searches (--glob) in combination with --extension @@ -361,7 +361,7 @@ fn test_glob_searches_with_extension() { te.assert_output( &["--glob", "--extension", "foo2", "[a-z].*"], - "./one/two/C.Foo2", + "one/two/C.Foo2", ); } @@ -370,7 +370,7 @@ fn test_glob_searches_with_extension() { fn test_regex_overrides_glob() { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); - te.assert_output(&["--glob", "--regex", "Foo2$"], "./one/two/C.Foo2"); + te.assert_output(&["--glob", "--regex", "Foo2$"], "one/two/C.Foo2"); } /// Full path search (--full-path) @@ -386,8 +386,8 @@ fn test_full_path() { "--full-path", &format!("^{prefix}.*three.*foo$", prefix = prefix), ], - "./one/two/three/d.foo - ./one/two/three/directory_foo/", + "one/two/three/d.foo + one/two/three/directory_foo/", ); } @@ -398,13 +398,13 @@ fn test_hidden() { te.assert_output( &["--hidden", "foo"], - "./.hidden.foo - ./a.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/d.foo - ./one/two/three/directory_foo/", + ".hidden.foo + a.foo + one/b.foo + one/two/c.foo + one/two/C.Foo2 + one/two/three/d.foo + one/two/three/directory_foo/", ); } @@ -426,7 +426,7 @@ fn test_hidden_file_attribute() { .open(te.test_root().join("hidden-file.txt")) .unwrap(); - te.assert_output(&["--hidden", "hidden-file.txt"], "./hidden-file.txt"); + te.assert_output(&["--hidden", "hidden-file.txt"], "hidden-file.txt"); te.assert_output(&["hidden-file.txt"], ""); } @@ -437,27 +437,27 @@ fn test_no_ignore() { te.assert_output( &["--no-ignore", "foo"], - "./a.foo - ./fdignored.foo - ./gitignored.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/d.foo - ./one/two/three/directory_foo/", + "a.foo + fdignored.foo + gitignored.foo + one/b.foo + one/two/c.foo + one/two/C.Foo2 + one/two/three/d.foo + one/two/three/directory_foo/", ); te.assert_output( &["--hidden", "--no-ignore", "foo"], - "./.hidden.foo - ./a.foo - ./fdignored.foo - ./gitignored.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/d.foo - ./one/two/three/directory_foo/", + ".hidden.foo + a.foo + fdignored.foo + gitignored.foo + one/b.foo + one/two/c.foo + one/two/C.Foo2 + one/two/three/d.foo + one/two/three/directory_foo/", ); } @@ -482,20 +482,20 @@ fn test_gitignore_and_fdignore() { .write_all(b"ignored-by-gitignore\nignored-by-both") .unwrap(); - te.assert_output(&["ignored"], "./ignored-by-nothing"); + te.assert_output(&["ignored"], "ignored-by-nothing"); te.assert_output( &["--no-ignore-vcs", "ignored"], - "./ignored-by-nothing - ./ignored-by-gitignore", + "ignored-by-nothing + ignored-by-gitignore", ); te.assert_output( &["--no-ignore", "ignored"], - "./ignored-by-nothing - ./ignored-by-fdignore - ./ignored-by-gitignore - ./ignored-by-both", + "ignored-by-nothing + ignored-by-fdignore + ignored-by-gitignore + ignored-by-both", ); } @@ -521,13 +521,13 @@ fn test_no_ignore_parent() { .write_all(b"child-ignored") .unwrap(); - te.assert_output_subdirectory("inner", &[], "./not-ignored"); + te.assert_output_subdirectory("inner", &[], "not-ignored"); te.assert_output_subdirectory( "inner", &["--no-ignore-parent"], - "./parent-ignored - ./not-ignored", + "parent-ignored + not-ignored", ); } @@ -559,15 +559,15 @@ fn test_no_ignore_parent_inner_git() { te.assert_output_subdirectory( "inner", &[], - "./not-ignored - ./parent-ignored", + "not-ignored + parent-ignored", ); te.assert_output_subdirectory( "inner", &["--no-ignore-parent"], - "./not-ignored - ./parent-ignored", + "not-ignored + parent-ignored", ); } @@ -590,11 +590,11 @@ fn test_custom_ignore_precedence() { .write_all(b"!foo") .unwrap(); - te.assert_output(&["foo"], "./inner/foo"); + te.assert_output(&["foo"], "inner/foo"); - te.assert_output(&["--no-ignore-vcs", "foo"], "./inner/foo"); + te.assert_output(&["--no-ignore-vcs", "foo"], "inner/foo"); - te.assert_output(&["--no-ignore", "foo"], "./inner/foo"); + te.assert_output(&["--no-ignore", "foo"], "inner/foo"); } /// VCS ignored files (--no-ignore-vcs) @@ -604,13 +604,13 @@ fn test_no_ignore_vcs() { te.assert_output( &["--no-ignore-vcs", "foo"], - "./a.foo - ./gitignored.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/d.foo - ./one/two/three/directory_foo/", + "a.foo + gitignored.foo + one/b.foo + one/two/c.foo + one/two/C.Foo2 + one/two/three/d.foo + one/two/three/directory_foo/", ); } @@ -625,8 +625,8 @@ fn test_no_ignore_vcs_child_dir() { te.assert_output_subdirectory( "inner", &["--no-ignore-vcs", "foo"], - "./foo - ./gitignored.foo", + "foo + gitignored.foo", ); } @@ -643,9 +643,9 @@ fn test_custom_ignore_files() { te.assert_output( &["--ignore-file", "custom.ignore", "foo"], - "./a.foo - ./one/b.foo - ./one/two/c.foo", + "a.foo + one/b.foo + one/two/c.foo", ); } @@ -656,15 +656,15 @@ fn test_no_ignore_aliases() { te.assert_output( &["-u", "foo"], - "./.hidden.foo - ./a.foo - ./fdignored.foo - ./gitignored.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/d.foo - ./one/two/three/directory_foo/", + ".hidden.foo + a.foo + fdignored.foo + gitignored.foo + one/b.foo + one/two/c.foo + one/two/C.Foo2 + one/two/three/d.foo + one/two/three/directory_foo/", ); } @@ -675,10 +675,10 @@ fn test_follow() { te.assert_output( &["--follow", "c.foo"], - "./one/two/c.foo - ./one/two/C.Foo2 - ./symlink/c.foo - ./symlink/C.Foo2", + "one/two/c.foo + one/two/C.Foo2 + symlink/c.foo + symlink/C.Foo2", ); } @@ -733,20 +733,20 @@ fn test_follow_broken_symlink() { te.assert_output( &["symlink"], - "./broken_symlink - ./symlink", + "broken_symlink + symlink", ); te.assert_output( &["--type", "symlink", "symlink"], - "./broken_symlink - ./symlink", + "broken_symlink + symlink", ); te.assert_output(&["--type", "file", "symlink"], ""); te.assert_output( &["--follow", "--type", "symlink", "symlink"], - "./broken_symlink", + "broken_symlink", ); te.assert_output(&["--follow", "--type", "file", "symlink"], ""); } @@ -774,33 +774,33 @@ fn test_max_depth() { te.assert_output( &["--max-depth", "3"], - "./a.foo - ./e1 e2 - ./one/ - ./one/b.foo - ./one/two/ - ./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/ - ./symlink", + "a.foo + e1 e2 + one/ + one/b.foo + one/two/ + one/two/c.foo + one/two/C.Foo2 + one/two/three/ + symlink", ); te.assert_output( &["--max-depth", "2"], - "./a.foo - ./e1 e2 - ./one/ - ./one/b.foo - ./one/two/ - ./symlink", + "a.foo + e1 e2 + one/ + one/b.foo + one/two/ + symlink", ); te.assert_output( &["--max-depth", "1"], - "./a.foo - ./e1 e2 - ./one/ - ./symlink", + "a.foo + e1 e2 + one/ + symlink", ); } @@ -811,17 +811,17 @@ fn test_min_depth() { te.assert_output( &["--min-depth", "3"], - "./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/ - ./one/two/three/d.foo - ./one/two/three/directory_foo/", + "one/two/c.foo + one/two/C.Foo2 + one/two/three/ + one/two/three/d.foo + one/two/three/directory_foo/", ); te.assert_output( &["--min-depth", "4"], - "./one/two/three/d.foo - ./one/two/three/directory_foo/", + "one/two/three/d.foo + one/two/three/directory_foo/", ); } @@ -832,9 +832,9 @@ fn test_exact_depth() { te.assert_output( &["--exact-depth", "3"], - "./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/", + "one/two/c.foo + one/two/C.Foo2 + one/two/three/", ); } @@ -843,32 +843,32 @@ fn test_exact_depth() { fn test_prune() { let dirs = &["foo/bar", "bar/foo", "baz"]; let files = &[ - "./foo/foo.file", - "./foo/bar/foo.file", - "./bar/foo.file", - "./bar/foo/foo.file", - "./baz/foo.file", + "foo/foo.file", + "foo/bar/foo.file", + "bar/foo.file", + "bar/foo/foo.file", + "baz/foo.file", ]; let te = TestEnv::new(dirs, files); te.assert_output( &["foo"], - "./foo/ - ./foo/foo.file - ./foo/bar/foo.file - ./bar/foo.file - ./bar/foo/ - ./bar/foo/foo.file - ./baz/foo.file", + "foo/ + foo/foo.file + foo/bar/foo.file + bar/foo.file + bar/foo/ + bar/foo/foo.file + baz/foo.file", ); te.assert_output( &["--prune", "foo"], - "./foo/ - ./bar/foo/ - ./bar/foo.file - ./baz/foo.file", + "foo/ + bar/foo/ + bar/foo.file + baz/foo.file", ); } @@ -955,34 +955,34 @@ fn test_type() { te.assert_output( &["--type", "f"], - "./a.foo - ./e1 e2 - ./one/b.foo - ./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/d.foo", + "a.foo + e1 e2 + one/b.foo + one/two/c.foo + one/two/C.Foo2 + one/two/three/d.foo", ); - te.assert_output(&["--type", "f", "e1"], "./e1 e2"); + te.assert_output(&["--type", "f", "e1"], "e1 e2"); te.assert_output( &["--type", "d"], - "./one/ - ./one/two/ - ./one/two/three/ - ./one/two/three/directory_foo/", + "one/ + one/two/ + one/two/three/ + one/two/three/directory_foo/", ); te.assert_output( &["--type", "d", "--type", "l"], - "./one/ - ./one/two/ - ./one/two/three/ - ./one/two/three/directory_foo/ - ./symlink", + "one/ + one/two/ + one/two/three/ + one/two/three/directory_foo/ + symlink", ); - te.assert_output(&["--type", "l"], "./symlink"); + te.assert_output(&["--type", "l"], "symlink"); } /// Test `--type executable` @@ -1000,15 +1000,15 @@ fn test_type_executable() { .open(te.test_root().join("executable-file.sh")) .unwrap(); - te.assert_output(&["--type", "executable"], "./executable-file.sh"); + te.assert_output(&["--type", "executable"], "executable-file.sh"); te.assert_output( &["--type", "executable", "--type", "directory"], - "./executable-file.sh - ./one/ - ./one/two/ - ./one/two/three/ - ./one/two/three/directory_foo/", + "executable-file.sh + one/ + one/two/ + one/two/three/ + one/two/three/directory_foo/", ); } @@ -1024,19 +1024,19 @@ fn test_type_empty() { te.assert_output( &["--type", "empty"], - "./0_bytes.foo - ./dir_empty/", + "0_bytes.foo + dir_empty/", ); te.assert_output( &["--type", "empty", "--type", "file", "--type", "directory"], - "./0_bytes.foo - ./dir_empty/", + "0_bytes.foo + dir_empty/", ); - te.assert_output(&["--type", "empty", "--type", "file"], "./0_bytes.foo"); + te.assert_output(&["--type", "empty", "--type", "file"], "0_bytes.foo"); - te.assert_output(&["--type", "empty", "--type", "directory"], "./dir_empty/"); + te.assert_output(&["--type", "empty", "--type", "directory"], "dir_empty/"); } /// File extension (--extension) @@ -1046,54 +1046,54 @@ fn test_extension() { te.assert_output( &["--extension", "foo"], - "./a.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/three/d.foo", + "a.foo + one/b.foo + one/two/c.foo + one/two/three/d.foo", ); te.assert_output( &["--extension", ".foo"], - "./a.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/three/d.foo", + "a.foo + one/b.foo + one/two/c.foo + one/two/three/d.foo", ); te.assert_output( &["--extension", ".foo", "--extension", "foo2"], - "./a.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/three/d.foo - ./one/two/C.Foo2", + "a.foo + one/b.foo + one/two/c.foo + one/two/three/d.foo + one/two/C.Foo2", ); - te.assert_output(&["--extension", ".foo", "a"], "./a.foo"); + te.assert_output(&["--extension", ".foo", "a"], "a.foo"); - te.assert_output(&["--extension", "foo2"], "./one/two/C.Foo2"); + te.assert_output(&["--extension", "foo2"], "one/two/C.Foo2"); let te2 = TestEnv::new(&[], &["spam.bar.baz", "egg.bar.baz", "yolk.bar.baz.sig"]); te2.assert_output( &["--extension", ".bar.baz"], - "./spam.bar.baz - ./egg.bar.baz", + "spam.bar.baz + egg.bar.baz", ); - te2.assert_output(&["--extension", "sig"], "./yolk.bar.baz.sig"); + te2.assert_output(&["--extension", "sig"], "yolk.bar.baz.sig"); - te2.assert_output(&["--extension", "bar.baz.sig"], "./yolk.bar.baz.sig"); + te2.assert_output(&["--extension", "bar.baz.sig"], "yolk.bar.baz.sig"); let te3 = TestEnv::new(&[], &["latin1.e\u{301}xt", "smiley.☻"]); - te3.assert_output(&["--extension", "☻"], "./smiley.☻"); + te3.assert_output(&["--extension", "☻"], "smiley.☻"); - te3.assert_output(&["--extension", ".e\u{301}xt"], "./latin1.e\u{301}xt"); + te3.assert_output(&["--extension", ".e\u{301}xt"], "latin1.e\u{301}xt"); let te4 = TestEnv::new(&[], &[".hidden", "test.hidden"]); - te4.assert_output(&["--hidden", "--extension", ".hidden"], "./test.hidden"); + te4.assert_output(&["--hidden", "--extension", ".hidden"], "test.hidden"); } /// No file extension (test for the pattern provided in the --help text) @@ -1106,21 +1106,21 @@ fn test_no_extension() { te.assert_output( &["^[^.]+$"], - "./aa - ./one/ - ./one/bb - ./one/two/ - ./one/two/three/ - ./one/two/three/d - ./one/two/three/directory_foo/ - ./symlink", + "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", + "aa + one/bb + one/two/three/d", ); } @@ -1255,46 +1255,46 @@ fn test_excludes() { te.assert_output( &["--exclude", "*.foo"], - "./one/ - ./one/two/ - ./one/two/C.Foo2 - ./one/two/three/ - ./one/two/three/directory_foo/ - ./e1 e2 - ./symlink", + "one/ + one/two/ + one/two/C.Foo2 + one/two/three/ + one/two/three/directory_foo/ + e1 e2 + symlink", ); te.assert_output( &["--exclude", "*.foo", "--exclude", "*.Foo2"], - "./one/ - ./one/two/ - ./one/two/three/ - ./one/two/three/directory_foo/ - ./e1 e2 - ./symlink", + "one/ + one/two/ + one/two/three/ + one/two/three/directory_foo/ + e1 e2 + symlink", ); te.assert_output( &["--exclude", "*.foo", "--exclude", "*.Foo2", "foo"], - "./one/two/three/directory_foo/", + "one/two/three/directory_foo/", ); te.assert_output( &["--exclude", "one/two/", "foo"], - "./a.foo - ./one/b.foo", + "a.foo + one/b.foo", ); te.assert_output( &["--exclude", "one/**/*.foo"], - "./a.foo - ./e1 e2 - ./one/ - ./one/two/ - ./one/two/C.Foo2 - ./one/two/three/ - ./one/two/three/directory_foo/ - ./symlink", + "a.foo + e1 e2 + one/ + one/two/ + one/two/C.Foo2 + one/two/three/ + one/two/three/directory_foo/ + symlink", ); } @@ -1677,12 +1677,12 @@ fn test_fixed_strings() { // Regex search, dot is treated as "any character" te.assert_output( &["a.foo"], - "./test1/a.foo - ./test1/a_foo", + "test1/a.foo + test1/a_foo", ); // Literal search, dot is treated as character - te.assert_output(&["--fixed-strings", "a.foo"], "./test1/a.foo"); + te.assert_output(&["--fixed-strings", "a.foo"], "test1/a.foo"); // Regex search, parens are treated as group te.assert_output(&["download (1)"], ""); @@ -1690,7 +1690,7 @@ fn test_fixed_strings() { // Literal search, parens are treated as characters te.assert_output( &["--fixed-strings", "download (1)"], - "./test2/Download (1).tar.gz", + "test2/Download (1).tar.gz", ); // Combine with --case-sensitive @@ -1736,81 +1736,69 @@ fn test_size() { // Zero and non-zero sized files. te.assert_output( &["", "--size", "+0B"], - "./0_bytes.foo - ./11_bytes.foo - ./30_bytes.foo - ./3_kilobytes.foo - ./4_kibibytes.foo", + "0_bytes.foo + 11_bytes.foo + 30_bytes.foo + 3_kilobytes.foo + 4_kibibytes.foo", ); // Zero sized files. - te.assert_output(&["", "--size", "-0B"], "./0_bytes.foo"); - te.assert_output(&["", "--size", "0B"], "./0_bytes.foo"); - te.assert_output(&["", "--size=0B"], "./0_bytes.foo"); - te.assert_output(&["", "-S", "0B"], "./0_bytes.foo"); + te.assert_output(&["", "--size", "-0B"], "0_bytes.foo"); + te.assert_output(&["", "--size", "0B"], "0_bytes.foo"); + te.assert_output(&["", "--size=0B"], "0_bytes.foo"); + te.assert_output(&["", "-S", "0B"], "0_bytes.foo"); // Files with 2 bytes or more. te.assert_output( &["", "--size", "+2B"], - "./11_bytes.foo - ./30_bytes.foo - ./3_kilobytes.foo - ./4_kibibytes.foo", + "11_bytes.foo + 30_bytes.foo + 3_kilobytes.foo + 4_kibibytes.foo", ); // Files with 2 bytes or less. - te.assert_output(&["", "--size", "-2B"], "./0_bytes.foo"); + te.assert_output(&["", "--size", "-2B"], "0_bytes.foo"); // Files with size between 1 byte and 11 bytes. - te.assert_output(&["", "--size", "+1B", "--size", "-11B"], "./11_bytes.foo"); + te.assert_output(&["", "--size", "+1B", "--size", "-11B"], "11_bytes.foo"); // Files with size equal 11 bytes. - te.assert_output(&["", "--size", "11B"], "./11_bytes.foo"); + te.assert_output(&["", "--size", "11B"], "11_bytes.foo"); // Files with size between 1 byte and 30 bytes. te.assert_output( &["", "--size", "+1B", "--size", "-30B"], - "./11_bytes.foo - ./30_bytes.foo", + "11_bytes.foo + 30_bytes.foo", ); // Combine with a search pattern - te.assert_output( - &["^11_", "--size", "+1B", "--size", "-30B"], - "./11_bytes.foo", - ); + te.assert_output(&["^11_", "--size", "+1B", "--size", "-30B"], "11_bytes.foo"); // Files with size between 12 and 30 bytes. - te.assert_output(&["", "--size", "+12B", "--size", "-30B"], "./30_bytes.foo"); + te.assert_output(&["", "--size", "+12B", "--size", "-30B"], "30_bytes.foo"); // Files with size between 31 and 100 bytes. te.assert_output(&["", "--size", "+31B", "--size", "-100B"], ""); // Files with size between 3 kibibytes and 5 kibibytes. - te.assert_output( - &["", "--size", "+3ki", "--size", "-5ki"], - "./4_kibibytes.foo", - ); + te.assert_output(&["", "--size", "+3ki", "--size", "-5ki"], "4_kibibytes.foo"); // Files with size between 3 kilobytes and 5 kilobytes. te.assert_output( &["", "--size", "+3k", "--size", "-5k"], - "./3_kilobytes.foo - ./4_kibibytes.foo", + "3_kilobytes.foo + 4_kibibytes.foo", ); // Files with size greater than 3 kilobytes and less than 3 kibibytes. - te.assert_output( - &["", "--size", "+3k", "--size", "-3ki"], - "./3_kilobytes.foo", - ); + te.assert_output(&["", "--size", "+3k", "--size", "-3ki"], "3_kilobytes.foo"); // Files with size equal 4 kibibytes. - te.assert_output( - &["", "--size", "+4ki", "--size", "-4ki"], - "./4_kibibytes.foo", - ); - te.assert_output(&["", "--size", "4ki"], "./4_kibibytes.foo"); + te.assert_output(&["", "--size", "+4ki", "--size", "-4ki"], "4_kibibytes.foo"); + te.assert_output(&["", "--size", "4ki"], "4_kibibytes.foo"); } #[cfg(test)] @@ -1846,23 +1834,23 @@ fn test_modified_relative() { te.assert_output( &["", "--changed-within", "15min"], - "./foo_0_now - ./bar_1_min - ./foo_10_min", + "foo_0_now + bar_1_min + foo_10_min", ); te.assert_output( &["", "--change-older-than", "15min"], - "./bar_1_h - ./foo_2_h - ./bar_1_day", + "bar_1_h + foo_2_h + bar_1_day", ); te.assert_output( &["foo", "--changed-within", "12h"], - "./foo_0_now - ./foo_10_min - ./foo_2_h", + "foo_0_now + foo_10_min + foo_2_h", ); } @@ -1882,11 +1870,11 @@ fn test_modified_absolute() { te.assert_output( &["", "--change-newer-than", "2018-01-01 00:00:00"], - "./15mar2018", + "15mar2018", ); te.assert_output( &["", "--changed-before", "2018-01-01 00:00:00"], - "./30dec2017", + "30dec2017", ); } @@ -1910,21 +1898,21 @@ fn test_base_directory() { te.assert_output( &["--base-directory", "one"], - "./b.foo - ./two/ - ./two/c.foo - ./two/C.Foo2 - ./two/three/ - ./two/three/d.foo - ./two/three/directory_foo/", + "b.foo + two/ + two/c.foo + two/C.Foo2 + two/three/ + two/three/d.foo + two/three/directory_foo/", ); te.assert_output( &["--base-directory", "one/two/", "foo"], - "./c.foo - ./C.Foo2 - ./three/d.foo - ./three/directory_foo/", + "c.foo + C.Foo2 + three/d.foo + three/directory_foo/", ); // Explicit root path @@ -1960,15 +1948,15 @@ fn test_max_results() { // Unrestricted te.assert_output( &["--max-results=0", "c.foo"], - "./one/two/C.Foo2 - ./one/two/c.foo", + "one/two/C.Foo2 + one/two/c.foo", ); // Limited to two results te.assert_output( &["--max-results=2", "c.foo"], - "./one/two/C.Foo2 - ./one/two/c.foo", + "one/two/C.Foo2 + one/two/c.foo", ); // Limited to one result. We could find either C.Foo2 or c.foo @@ -1977,7 +1965,7 @@ fn test_max_results() { let stdout = String::from_utf8_lossy(&output.stdout) .trim() .replace(&std::path::MAIN_SEPARATOR.to_string(), "/"); - assert!(stdout == "./one/two/C.Foo2" || stdout == "./one/two/c.foo"); + assert!(stdout == "one/two/C.Foo2" || stdout == "one/two/c.foo"); }; assert_just_one_result_with_option("--max-results=1"); assert_just_one_result_with_option("-1"); @@ -2090,8 +2078,8 @@ fn test_error_if_hidden_not_set_and_pattern_starts_with_dot() { te.assert_failure(&["^\\.gitignore"]); te.assert_failure(&["--glob", ".gitignore"]); - te.assert_output(&["--hidden", "^\\.gitignore"], "./.gitignore"); - te.assert_output(&["--hidden", "--glob", ".gitignore"], "./.gitignore"); + te.assert_output(&["--hidden", "^\\.gitignore"], ".gitignore"); + te.assert_output(&["--hidden", "--glob", ".gitignore"], ".gitignore"); te.assert_output(&[".gitignore"], ""); } From 8ccf21437b3af81bb74307b4f1ea91b415a6cc3b Mon Sep 17 00:00:00 2001 From: Kamil Aronowski Date: Wed, 14 Sep 2022 11:58:51 +0200 Subject: [PATCH 16/24] Mention EuroLinux --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ca1a73..0b5acf4 100644 --- a/README.md +++ b/README.md @@ -599,7 +599,7 @@ You can install `fd` via xbps-install: xbps-install -S fd ``` -### On RedHat Enterprise Linux 8 (RHEL8) or Almalinux 8 or Rocky Linux 8 +### On RedHat Enterprise Linux 8 (RHEL8), Almalinux 8, EuroLinux 8 or Rocky Linux 8 Get the latest fd-v*-x86_64-unknown-linux-gnu.tar.gz file from [sharkdp on github](https://github.com/sharkdp/fd/releases) ``` From 12142008df0a367bf2119f1752de05f6ada6061a Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Wed, 14 Sep 2022 14:10:34 -0700 Subject: [PATCH 17/24] Add a link back to Github to `--help` (but not `-h`) --- src/app.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app.rs b/src/app.rs index 5348ade..502b13e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -16,6 +16,9 @@ pub fn build_app() -> Command<'static> { "Note: `fd -h` prints a short and concise overview while `fd --help` gives all \ details.", ) + .after_long_help( + "Bugs can be reported on Github: https://github.com/sharkdp/fd" + ) .arg( Arg::new("hidden") .long("hidden") From e3e6057434371edf5e6927e5131ec0cb07a27a20 Mon Sep 17 00:00:00 2001 From: David Peter Date: Tue, 27 Sep 2022 21:00:17 +0200 Subject: [PATCH 18/24] Minor adaptation to help text --- src/app.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index 502b13e..1a904d1 100644 --- a/src/app.rs +++ b/src/app.rs @@ -17,7 +17,7 @@ pub fn build_app() -> Command<'static> { details.", ) .after_long_help( - "Bugs can be reported on Github: https://github.com/sharkdp/fd" + "Bugs can be reported on GitHub: https://github.com/sharkdp/fd/issues" ) .arg( Arg::new("hidden") From 4f1bcfedf32eb662fa7c67319f3a113219fc0da9 Mon Sep 17 00:00:00 2001 From: David Peter Date: Tue, 27 Sep 2022 21:25:10 +0200 Subject: [PATCH 19/24] Update CHANGELOG --- CHANGELOG.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f97ec0..ccc46ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,20 +2,25 @@ ## Features -- `--type executable`/`-t` now works on Windows, see #1051 and #1061 +- `--type executable`/`-t` now works on Windows, see #1051 and #1061 (@tavianator) ## Bugfixes -- fd returns an error when current working directory does not exist while a search path is specified, see #1072 (@vijfhoek) +- Fixed differences between piped / non-piped output. This changes `fd`s behavior back to what we + had before 8.3.0, i.e. there will be no leading `./` prefixes, unless the `--print0`/`-0` option + is used. `--strip-cwd-prefix` can be used to strip that prefix even when `--print0` is used, + see #1046 and #1115 (@tavianator) +- fd returns an error when current working directory does not exist while a search path is + specified, see #1072 (@vijfhoek) - Improved "command not found" error message, see #1083 and #1109 (@themkat) - ## Changes +- No leading `./` prefix for non-interactive results, see above. ## Other -- Added link back to GitHub in man page, see #1086 (@scottchiefbaker) +- Added link back to GitHub in man page and `--help` text, see #1086 (@scottchiefbaker) # v8.4.0 From 46c38a827e59f0303fbdf755ea5cd2fe661a2d3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Oct 2022 17:02:17 +0000 Subject: [PATCH 20/24] Bump libc from 0.2.132 to 0.2.134 Bumps [libc](https://github.com/rust-lang/libc) from 0.2.132 to 0.2.134. - [Release notes](https://github.com/rust-lang/libc/releases) - [Commits](https://github.com/rust-lang/libc/compare/0.2.132...0.2.134) --- updated-dependencies: - dependency-name: libc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4055e5f..462392d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -399,9 +399,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.132" +version = "0.2.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" [[package]] name = "log" From b1ee6e304666f7105037746127a6515a19da0679 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Oct 2022 17:02:24 +0000 Subject: [PATCH 21/24] Bump once_cell from 1.14.0 to 1.15.0 Bumps [once_cell](https://github.com/matklad/once_cell) from 1.14.0 to 1.15.0. - [Release notes](https://github.com/matklad/once_cell/releases) - [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md) - [Commits](https://github.com/matklad/once_cell/compare/v1.14.0...v1.15.0) --- updated-dependencies: - dependency-name: once_cell dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4055e5f..f1e7bf8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -490,9 +490,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" [[package]] name = "os_str_bytes" diff --git a/Cargo.toml b/Cargo.toml index f41e792..5f627fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ anyhow = "1.0" dirs-next = "2.0" normpath = "0.3.2" chrono = "0.4" -once_cell = "1.13.1" +once_cell = "1.15.0" [dependencies.clap] version = "3.1" From 3f33b15e5290e43849e37e207ee0175a04acbd1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Oct 2022 17:02:33 +0000 Subject: [PATCH 22/24] Bump anyhow from 1.0.64 to 1.0.65 Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.64 to 1.0.65. - [Release notes](https://github.com/dtolnay/anyhow/releases) - [Commits](https://github.com/dtolnay/anyhow/compare/1.0.64...1.0.65) --- updated-dependencies: - dependency-name: anyhow dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4055e5f..f3b27b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,9 +31,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9a8f622bcf6ff3df478e9deba3e03e4e04b300f8e6a139e192c05fa3490afc7" +checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" [[package]] name = "argmax" From 4ffc34956f9a00d3d5279758feabb5862f5dc9c4 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 27 Sep 2022 16:09:21 -0400 Subject: [PATCH 23/24] Make --strip-cwd-prefix apply to -x/-X Fixes #898. --- src/app.rs | 6 ++++-- src/dir_entry.rs | 21 +++++++++++++++++++++ src/exec/job.rs | 28 +++++++++++++++------------- src/main.rs | 7 +++++-- src/output.rs | 17 +++-------------- src/walk.rs | 16 +++------------- tests/tests.rs | 15 +++++++++++++++ 7 files changed, 66 insertions(+), 44 deletions(-) diff --git a/src/app.rs b/src/app.rs index 1a904d1..fa9416a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -724,8 +724,10 @@ pub fn build_app() -> Command<'static> { .hide_short_help(true) .help("strip './' prefix from -0/--print0 output") .long_help( - "By default, relative paths are prefixed with './' when -0/--print0 is given, to \ - make them safer for use with xargs. Use this flag to disable this behaviour." + "By default, relative paths are prefixed with './' when -x/--exec, \ + -X/--exec-batch, or -0/--print0 are given, to reduce the risk of a \ + path starting with '-' being treated as a command line option. Use \ + this flag to disable this behaviour." ) ); diff --git a/src/dir_entry.rs b/src/dir_entry.rs index 5def5de..7c34be5 100644 --- a/src/dir_entry.rs +++ b/src/dir_entry.rs @@ -5,6 +5,9 @@ use std::{ use once_cell::unsync::OnceCell; +use crate::config::Config; +use crate::filesystem::strip_current_dir; + enum DirEntryInner { Normal(ignore::DirEntry), BrokenSymlink(PathBuf), @@ -45,6 +48,24 @@ impl DirEntry { } } + /// Returns the path as it should be presented to the user. + pub fn stripped_path(&self, config: &Config) -> &Path { + if config.strip_cwd_prefix { + strip_current_dir(self.path()) + } else { + self.path() + } + } + + /// Returns the path as it should be presented to the user. + pub fn into_stripped_path(self, config: &Config) -> PathBuf { + if config.strip_cwd_prefix { + self.stripped_path(config).to_path_buf() + } else { + self.into_path() + } + } + pub fn file_type(&self) -> Option { match &self.inner { DirEntryInner::Normal(e) => e.file_type(), diff --git a/src/exec/job.rs b/src/exec/job.rs index 9b95ac2..b803f79 100644 --- a/src/exec/job.rs +++ b/src/exec/job.rs @@ -1,6 +1,7 @@ use std::sync::mpsc::Receiver; use std::sync::{Arc, Mutex}; +use crate::config::Config; use crate::dir_entry::DirEntry; use crate::error::print_error; use crate::exit_codes::{merge_exitcodes, ExitCode}; @@ -15,9 +16,11 @@ pub fn job( rx: Arc>>, cmd: Arc, out_perm: Arc>, - show_filesystem_errors: bool, - buffer_output: bool, + config: &Config, ) -> ExitCode { + // Output should be buffered when only running a single thread + let buffer_output: bool = config.threads > 1; + let mut results: Vec = Vec::new(); loop { // Create a lock on the shared receiver for this thread. @@ -28,7 +31,7 @@ pub fn job( let dir_entry: DirEntry = match lock.recv() { Ok(WorkerResult::Entry(dir_entry)) => dir_entry, Ok(WorkerResult::Error(err)) => { - if show_filesystem_errors { + if config.show_filesystem_errors { print_error(err.to_string()); } continue; @@ -39,29 +42,28 @@ pub fn job( // Drop the lock so that other threads can read from the receiver. drop(lock); // Generate a command, execute it and store its exit code. - results.push(cmd.execute(dir_entry.path(), Arc::clone(&out_perm), buffer_output)) + results.push(cmd.execute( + dir_entry.stripped_path(config), + Arc::clone(&out_perm), + buffer_output, + )) } // Returns error in case of any error. merge_exitcodes(results) } -pub fn batch( - rx: Receiver, - cmd: &CommandSet, - show_filesystem_errors: bool, - limit: usize, -) -> ExitCode { +pub fn batch(rx: Receiver, cmd: &CommandSet, config: &Config) -> ExitCode { let paths = rx .into_iter() .filter_map(|worker_result| match worker_result { - WorkerResult::Entry(dir_entry) => Some(dir_entry.into_path()), + WorkerResult::Entry(dir_entry) => Some(dir_entry.into_stripped_path(config)), WorkerResult::Error(err) => { - if show_filesystem_errors { + if config.show_filesystem_errors { print_error(err.to_string()); } None } }); - cmd.execute_batch(paths, limit) + cmd.execute_batch(paths, config.batch_size) } diff --git a/src/main.rs b/src/main.rs index dba6d4b..ece5b4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -383,9 +383,12 @@ fn construct_config(matches: clap::ArgMatches, pattern_regex: &str) -> Result String { path.replace(std::path::MAIN_SEPARATOR, new_path_separator) } -fn stripped_path<'a>(entry: &'a DirEntry, config: &Config) -> &'a Path { - let path = entry.path(); - if config.strip_cwd_prefix { - strip_current_dir(path) - } else { - path - } -} - // TODO: this function is performance critical and can probably be optimized pub fn print_entry(stdout: &mut W, entry: &DirEntry, config: &Config) { let r = if let Some(ref ls_colors) = config.ls_colors { @@ -74,7 +63,7 @@ fn print_entry_colorized( ) -> io::Result<()> { // Split the path between the parent and the last component let mut offset = 0; - let path = stripped_path(entry, config); + let path = entry.stripped_path(config); let path_str = path.to_string_lossy(); if let Some(parent) = path.parent() { @@ -130,7 +119,7 @@ fn print_entry_uncolorized_base( config: &Config, ) -> io::Result<()> { let separator = if config.null_separator { "\0" } else { "\n" }; - let path = stripped_path(entry, config); + let path = entry.stripped_path(config); let mut path_string = path.to_string_lossy(); if let Some(ref separator) = config.path_separator { @@ -164,7 +153,7 @@ fn print_entry_uncolorized( } else { // Print path as raw bytes, allowing invalid UTF-8 filenames to be passed to other processes let separator = if config.null_separator { b"\0" } else { b"\n" }; - stdout.write_all(stripped_path(entry, config).as_os_str().as_bytes())?; + stdout.write_all(entry.stripped_path(config).as_os_str().as_bytes())?; print_trailing_slash(stdout, entry, config, None)?; stdout.write_all(separator) } diff --git a/src/walk.rs b/src/walk.rs index 463417e..62dcc78 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -341,15 +341,12 @@ fn spawn_receiver( let quit_flag = Arc::clone(quit_flag); let interrupt_flag = Arc::clone(interrupt_flag); - let show_filesystem_errors = config.show_filesystem_errors; let threads = config.threads; - // This will be used to check if output should be buffered when only running a single thread - let enable_output_buffering: bool = threads > 1; thread::spawn(move || { // This will be set to `Some` if the `--exec` argument was supplied. if let Some(ref cmd) = config.command { if cmd.in_batch_mode() { - exec::batch(rx, cmd, show_filesystem_errors, config.batch_size) + exec::batch(rx, cmd, &config) } else { let shared_rx = Arc::new(Mutex::new(rx)); @@ -358,20 +355,13 @@ fn spawn_receiver( // Each spawned job will store it's thread handle in here. let mut handles = Vec::with_capacity(threads); for _ in 0..threads { + let config = Arc::clone(&config); let rx = Arc::clone(&shared_rx); let cmd = Arc::clone(cmd); let out_perm = Arc::clone(&out_perm); // Spawn a job thread that will listen for and execute inputs. - let handle = thread::spawn(move || { - exec::job( - rx, - cmd, - out_perm, - show_filesystem_errors, - enable_output_buffering, - ) - }); + let handle = thread::spawn(move || exec::job(rx, cmd, out_perm, &config)); // Push the handle of the spawned thread into the vector for later joining. handles.push(handle); diff --git a/tests/tests.rs b/tests/tests.rs index 0bed407..50157c4 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1327,6 +1327,16 @@ fn test_exec() { ./one/two/three/directory_foo", ); + te.assert_output( + &["foo", "--strip-cwd-prefix", "--exec", "echo", "{}"], + "a.foo + one/b.foo + one/two/C.Foo2 + one/two/c.foo + one/two/three/d.foo + one/two/three/directory_foo", + ); + te.assert_output( &["foo", "--exec", "echo", "{.}"], "a @@ -1452,6 +1462,11 @@ fn test_exec_batch() { "./a.foo ./one/b.foo ./one/two/C.Foo2 ./one/two/c.foo ./one/two/three/d.foo ./one/two/three/directory_foo", ); + te.assert_output( + &["foo", "--strip-cwd-prefix", "--exec-batch", "echo", "{}"], + "a.foo one/b.foo one/two/C.Foo2 one/two/c.foo one/two/three/d.foo one/two/three/directory_foo", + ); + te.assert_output( &["foo", "--exec-batch", "echo", "{/}"], "a.foo b.foo C.Foo2 c.foo d.foo directory_foo", From 0984ed91eacb0823d192a22e37e1f1b427c189c4 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 2 Oct 2022 10:01:59 -0400 Subject: [PATCH 24/24] Update CHANGELOG for -x/-X leading ./ change --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccc46ac..53df238 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,9 @@ ## Bugfixes - Fixed differences between piped / non-piped output. This changes `fd`s behavior back to what we - had before 8.3.0, i.e. there will be no leading `./` prefixes, unless the `--print0`/`-0` option - is used. `--strip-cwd-prefix` can be used to strip that prefix even when `--print0` is used, - see #1046 and #1115 (@tavianator) + had before 8.3.0, i.e. there will be no leading `./` prefixes, unless `--exec`/`-x`, + `--exec-batch`/`-X`, or `--print0`/`-0` are used. `--strip-cwd-prefix` can be used to strip that + prefix in those cases. See #1046, #1115, and #1121 (@tavianator) - fd returns an error when current working directory does not exist while a search path is specified, see #1072 (@vijfhoek) - Improved "command not found" error message, see #1083 and #1109 (@themkat)