| 297 | } |
| 298 | |
| 299 | fn split_command_string(command: &str) -> (String, Vec<String>) { |
| 300 | let mut parts = Vec::new(); |
| 301 | let mut current = String::new(); |
| 302 | let mut in_quotes = false; |
| 303 | let mut quote_char = '\0'; |
| 304 | |
| 305 | for c in command.chars() { |
| 306 | match c { |
| 307 | '"' | '\'' if !in_quotes => { |
| 308 | in_quotes = true; |
| 309 | quote_char = c; |
| 310 | } |
| 311 | '"' | '\'' if in_quotes && c == quote_char => { |
| 312 | in_quotes = false; |
| 313 | } |
| 314 | ' ' if !in_quotes => { |
| 315 | if !current.is_empty() { |
| 316 | parts.push(std::mem::take(&mut current)); |
| 317 | } |
| 318 | } |
| 319 | _ => current.push(c), |
| 320 | } |
| 321 | } |
| 322 | if !current.is_empty() { |
| 323 | parts.push(current); |
| 324 | } |
| 325 | |
| 326 | let mut iter = parts.into_iter(); |
| 327 | let exe = iter.next().expect("Command should have at least a program name"); |
| 328 | (exe, iter.collect()) |
| 329 | } |
| 330 | |
| 331 | // Note: this function is memoized to ensure we only compile each client once. |
| 332 | fn compile_client(compile_command: &str, client_project: &str) { |