Fix match behavior for delete "."

This commit is contained in:
Chad Williamson
2021-01-01 09:32:24 -08:00
parent 11617ae0e8
commit c58f70e0da
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -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()) {
+3 -2
View File
@@ -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");