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 Jun 1, 2024
1 parent ff45b10 commit 3805547
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 @@ -67,24 +67,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 @@ -105,6 +87,25 @@ impl Matcher for SingleExecMatcher {
}
}
}

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

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

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/exec.rs#L93

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

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

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/exec.rs#L96

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L99 - L100 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

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

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

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/exec.rs#L105

Added line #L105 was not covered by tests
}
}

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

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/exec.rs#L107

Added line #L107 was not covered by tests

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

0 comments on commit 3805547

Please sign in to comment.