fix: not trimming opts

This commit is contained in:
iff 2024-11-19 03:54:41 +01:00
parent 0dc24bc21d
commit 070343a5e2

View file

@ -81,13 +81,17 @@ pub fn check_executable(shell: &str, executable: &str) -> bool {
pub fn opt_regex(regex: &str, command: &mut String) -> String { pub fn opt_regex(regex: &str, command: &mut String) -> String {
let regex = Regex::new(regex).unwrap(); let regex = Regex::new(regex).unwrap();
let mut opt = Vec::new(); let mut opts = Vec::new();
for captures in regex.captures_iter(command) { for captures in regex.captures_iter(command) {
for cap in captures.iter().skip(1).flatten() { for cap in captures.iter().skip(1).flatten() {
opt.push(cap.as_str().to_owned()); opts.push(cap.as_str().to_owned());
} }
} }
opt.join(" ")
for opt in opts.clone() {
*command = command.replace(&opt, "");
}
opts.join(" ")
} }
pub fn err_regex(regex: &str, error_msg: &str) -> String { pub fn err_regex(regex: &str, error_msg: &str) -> String {