kvarn::prelude::utils

Function quoted_str_split

source
pub fn quoted_str_split(s: &str) -> QuotedStrSplitIter<'_> 
Expand description

Shell-like splitting of s.

Quotes (both single and double) and backslashes \ disables spaces’ effect.

§Examples

This is quote a convoluted example which shows some of the more intrecate edge-cases. Refer to the tests at the bottom of this source file for more examples.

let s = r#"program arg1 'arg "'two\ st\"il"l goes "on. 'third-arg "#;
assert_eq!(quoted_str_split(s).collect::<Vec<_>>(), ["program", "arg1", "arg \"two st\"ill goes on.", "third-arg "]);