fix: modules

This commit is contained in:
iff 2024-12-08 15:33:43 +01:00
parent 5aebf867c1
commit fedee1dc8d
12 changed files with 54 additions and 39 deletions

View file

@ -1,5 +1,5 @@
use regex_lite::Regex;
use crate::files::*;
use regex_lite::Regex;
pub fn opt_regex(regex: &str, command: &mut String) -> String {
let regex = Regex::new(regex).unwrap();
@ -56,9 +56,8 @@ pub fn eval_shell_command(shell: &str, command: &str) -> Vec<String> {
}
pub fn split_command(command: &str) -> Vec<String> {
if cfg!(debug_assertions) {
eprintln!("command: {command}")
}
#[cfg(debug_assertions)]
eprintln!("command: {command}");
// this regex splits the command separated by spaces, except when the space
// is escaped by a backslash or surrounded by quotes
let regex = r#"([^\s"'\\]+|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\\ )+|\\|\n"#;
@ -152,4 +151,3 @@ pub fn compare_string(a: &str, b: &str) -> usize {
}
matrix[a.chars().count()][b.chars().count()]
}