find: use GNU wording "unknown predicate" for unrecognized args

GNU find rejects an unrecognized predicate with
"find: unknown predicate '<arg>'", but we printed
"find: Unrecognized flag: '<arg>'". Match GNU so the
tests/find/refuse-noop GNU test (and others hitting the same path)
pass. Add an integration test covering -noop and ---noop.
This commit is contained in:
Sylvestre Ledru
2026-06-09 22:40:43 +02:00
parent 53980035af
commit efe6dc05f9
3 changed files with 20 additions and 2 deletions
+1 -1
View File
@@ -975,7 +975,7 @@ fn build_matcher_tree(
)
}
}
None => return Err(From::from(format!("Unrecognized flag: '{}'", args[i]))),
None => return Err(From::from(format!("unknown predicate '{}'", args[i]))),
}
}
};
+1 -1
View File
@@ -546,7 +546,7 @@ mod tests {
//
let result = super::parse_args(&["-asdadsafsfsadcs"]);
if let Err(e) = result {
assert_eq!(e.to_string(), "Unrecognized flag: '-asdadsafsfsadcs'");
assert_eq!(e.to_string(), "unknown predicate '-asdadsafsfsadcs'");
} else {
panic!("parse_args should have returned an error");
}
+18
View File
@@ -82,6 +82,24 @@ fn multiple_matcher_success() {
.stdout_contains("abbbc");
}
#[test]
fn unknown_predicate_is_rejected() {
// GNU find rejects an unrecognized predicate with
// "find: unknown predicate '<arg>'" and exit code 1 (see the GNU
// testsuite's tests/find/refuse-noop test).
ucmd()
.arg("-noop")
.fails()
.stderr_contains("unknown predicate '-noop'")
.no_stdout();
ucmd()
.arg("---noop")
.fails()
.stderr_contains("unknown predicate '---noop'")
.no_stdout();
}
#[test]
fn multiple_matcher_failure() {
ucmd()