From 87c5caa7795acead13b0f52569932c08c3496eb6 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 28 Mar 2021 13:37:11 -0400 Subject: [PATCH] Make multi-exec only match {} + with nothing in between Fixes #40. --- src/find/matchers/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/find/matchers/mod.rs b/src/find/matchers/mod.rs index 3e15cdc8..bee79e6d 100644 --- a/src/find/matchers/mod.rs +++ b/src/find/matchers/mod.rs @@ -269,7 +269,7 @@ fn build_matcher_tree( "-exec" | "-execdir" => { let mut arg_index = i + 1; while arg_index < args.len() && args[arg_index] != ";" { - if args[arg_index] == "+" { + if args[arg_index - 1] == "{}" && args[arg_index] == "+" { // MultiExecMatcher isn't written yet return Err(From::from(format!( "{} [args...] + isn't supported yet. \ @@ -948,6 +948,13 @@ mod tests { .expect("parsing argument list with exec that takes brackets and -os should work"); } + #[test] + fn build_top_level_exec_plus_semicolon() { + let mut config = Config::default(); + build_top_level_matcher(&["-exec", "foo", "{}", "foo", "+", ";"], &mut config) + .expect("only {} + should be considered a multi-exec"); + } + #[test] #[cfg(unix)] fn build_top_level_matcher_perm() {