Process module

break_command_into_strings

procedure · 1 overloadSource

Splits a command line into words: the pieces between spaces, where a piece in double quotes may hold spaces and loses its quotes.

break_command_into_strings :: (input: string) -> [..] string

There are no escapes and no other separators. The words are slices of input, valid as long as it is, and the array is in temporary storage (temp), so neither is freed. An empty line gives no words; an unclosed quote runs to the end of the line.

Parameters

input: string

Returns

[..] string
Example
words := break_command_into_strings(" maple   \"red tree\" cedar ");
assert(words.count == 3);
assert(words[0] == "maple" && words[1] == "red tree" && words[2] == "cedar");

Doesn't run in the browser (skipped on wasm).

See also