Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrIncompleteCommand = errors.New("incomplete command")
)
Functions ¶
func Parse ¶
Parse implements shell-esque string-splitting rules, similar to Python's shlex.
Parsing ends when all arguments are successfully consumed, when invalid syntax is encountered, or when one of the characters in 'endset' is encountered while scanning for the start of the next argument.
The input string is stripped of leading and trailing whitespace. Whitespace is defined as '\r', '\n', '\t' and ' '.
Strings within cmd can be single-quoted, double-quoted or unquoted. Empty strings are allowed.
An unquoted string ends at the first occurence of whitespace or the end of cmd.
Quote characters are not recognized within words; `Do"Not"Separate` is parsed as the single word `Do"Not"Separate`.
Enclosing characters in single-quotes ( ” ) shall preserve the literal value of each character within the single-quotes. A single-quote cannot occur within single-quotes.
Enclosing characters in double-quotes ( "" ) shall preserve the literal value of all characters within the double-quotes, with the exception of <backslash>, explained below.
The <backslash> shall retain its special meaning as an escape character when present in the following two-byte sequences, producing the output on the right side:
0x5c 0x6e (\n) --> 0x0a 0x5c 0x0a (\\n) --> <nothing> 0x5c 0x22 (\") --> 0x22 0x5c 0x5c (\\) --> 0x5c
All other backslashes are copied literally into the output:
0x5c 0x61 (\a) --> 0x5c 0x61
Types ¶
This section is empty.