Skip to main content

split_shell_commands

Function split_shell_commands 

Source
pub fn split_shell_commands(cmd: &str) -> Vec<&str>
Expand description

Split a shell command string on unquoted ;, &&, and || operators.

Returns a list of sub-commands with each segment trimmed of whitespace. Characters inside single quotes, double quotes, or backticks are treated as literal and are never split. Escaped quotes (\', \") do not toggle quote state. Pipes (|) within a segment are preserved (they are part of one command, not a command separator).

Performance: single-pass O(n) character state machine, no regex, no heap allocation for the common single-command case.