Skip to content

Commit

Permalink
Fix -ok and -okdir abnormal parameter detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbings authored and sylvestre committed Sep 9, 2024
1 parent bdbcca9 commit 18b88ff
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/find/matchers/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,6 @@ impl Matcher for SingleExecMatcher {
file_info.path().to_path_buf()
};

// support interactive exec
if self.interactive {
let tips = format!(
"{} ... {} > ? [y/n]: ",
self.executable,
path_to_file.to_string_lossy()
);
#[allow(clippy::explicit_write)]
write!(stdout(), "{}", tips).unwrap();
stdout().flush().unwrap();

let mut input = String::new();
let _result = stdin().read_line(&mut input).unwrap();
if !input.trim().contains('y') {
return false;
}
}

for arg in &self.args {
match *arg {
Arg::LiteralArg(ref a) => command.arg(a.as_os_str()),
Expand All @@ -104,6 +86,25 @@ impl Matcher for SingleExecMatcher {
}
}
}

// support interactive exec
if self.interactive {
let tips = format!(

Check warning on line 92 in src/find/matchers/exec.rs

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/exec.rs#L92

Added line #L92 was not covered by tests
"{} ... {} > ? [y/n]: ",
self.executable,
path_to_file.to_string_lossy()

Check warning on line 95 in src/find/matchers/exec.rs

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/exec.rs#L95

Added line #L95 was not covered by tests
);
#[allow(clippy::explicit_write)]
write!(stdout(), "{}", tips).unwrap();
stdout().flush().unwrap();

Check warning on line 99 in src/find/matchers/exec.rs

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/exec.rs#L98-L99

Added lines #L98 - L99 were not covered by tests

let mut input = String::new();
let _result = stdin().read_line(&mut input).unwrap();

Check warning on line 102 in src/find/matchers/exec.rs

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/exec.rs#L101-L102

Added lines #L101 - L102 were not covered by tests
if !input.trim().contains('y') {
return false;

Check warning on line 104 in src/find/matchers/exec.rs

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/exec.rs#L104

Added line #L104 was not covered by tests
}
}

Check warning on line 106 in src/find/matchers/exec.rs

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/exec.rs#L106

Added line #L106 was not covered by tests

match command.status() {
Ok(status) => status.success(),
Err(e) => {
Expand Down

0 comments on commit 18b88ff

Please sign in to comment.