fix: don't include non-espaced space in regex

This commit is contained in:
iff 2023-08-09 17:46:40 +02:00
parent dc7f7e9c8d
commit 60616750ea

View file

@ -113,7 +113,7 @@ fn eval_shell_command(shell: &str, command: &str) -> Vec<String> {
pub fn split_command(command: &str) -> Vec<String> {
// 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"'\\]+|"(?:\\.|[^"\\])*"|\\.+|'(?:\\.|[^'\\])*'|\\.)+"#;
let regex = r#"([^\s"'\\]+|"(?:\\.|[^"\\])*"|\\\s+|'(?:\\.|[^'\\])*'|\\\s)+"#;
let regex = Regex::new(regex).unwrap();
let split_command = regex
.find_iter(command)