diff --git a/src/find/matchers/delete.rs b/src/find/matchers/delete.rs index 31a5d56..20653e2 100644 --- a/src/find/matchers/delete.rs +++ b/src/find/matchers/delete.rs @@ -44,7 +44,7 @@ impl Matcher for DeleteMatcher { // POSIX rmdir() not accepting "." (EINVAL). std::fs::remove_dir() // inherits the same behavior, so no reason to buck tradition. if path_str == "." { - return false; + return true; } match self.delete(path, file_info.file_type()) { diff --git a/tests/find_cmd_tests.rs b/tests/find_cmd_tests.rs index a26ae35..f0d5a1c 100644 --- a/tests/find_cmd_tests.rs +++ b/tests/find_cmd_tests.rs @@ -100,13 +100,14 @@ fn delete_on_dot_dir() { let original_dir = env::current_dir().unwrap(); env::set_current_dir(&temp_dir.path()).expect("working dir changed"); + // "." should be matched (confirmed by the print), but not deleted. Command::cargo_bin("find") .expect("found binary") - .args(&[".", "-delete"]) + .args(&[".", "-delete", "-print"]) .assert() .success() .stderr(predicate::str::is_empty()) - .stdout(predicate::str::is_empty()); + .stdout(predicate::str::similar(".\n")); env::set_current_dir(original_dir).expect("restored original working dir");