mirror of
https://github.com/uutils/findutils.git
synced 2026-06-10 15:48:30 -07:00
Fix match behavior for delete "."
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user