2022-06-07 19:00:46 -04:00
|
|
|
# TODO: move here test cases from tests/test_cmdline.c
|
|
|
|
|
|
|
|
- cmdline: ''
|
|
|
|
result: []
|
|
|
|
- cmdline: ' '
|
|
|
|
result: []
|
|
|
|
- cmdline: 'foo'
|
|
|
|
result: ['foo']
|
|
|
|
- cmdline: 'foo bar'
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: 'foo bar '
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: ' foo bar '
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: 'foo bar'
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: ' foo bar'
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: 'foo bar '
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: ' foo bar '
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: 'foo bar car'
|
|
|
|
result: ['foo', 'bar', 'car']
|
|
|
|
|
|
|
|
- cmdline: '\"\"'
|
|
|
|
result: ['']
|
|
|
|
- cmdline: '\"\" \"\"'
|
|
|
|
result: ['', '']
|
|
|
|
- cmdline: '\"\" \"\" \"\"'
|
|
|
|
result: ['', '', '']
|
|
|
|
- cmdline: '\"foo\"'
|
|
|
|
result: ['foo']
|
|
|
|
- cmdline: '\"foo\" \"bar\"'
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: ' \"foo\" \"bar\"'
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: '\"foo\" \"bar\" '
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: ' \"foo\" \"bar\" '
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: '\"foo\" \"bar\"'
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: '\"foo\" \"bar\" '
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: ' \"foo\" \"bar\"'
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: ' \"foo\" \"bar\" '
|
|
|
|
result: ['foo', 'bar']
|
|
|
|
- cmdline: '\"foo\" \"bar\" \"car\"'
|
|
|
|
result: ['foo', 'bar', 'car']
|
|
|
|
|
|
|
|
- cmdline: 'foo bar car'
|
|
|
|
argv_count_max: 3
|
|
|
|
result: ['foo', 'bar', 'car']
|
|
|
|
- cmdline: 'foo bar car'
|
|
|
|
buffer_size: 12
|
|
|
|
result: ['foo', 'bar', 'car']
|
|
|
|
- cmdline: 'foo bar car'
|
|
|
|
argv_count_max: 3
|
|
|
|
buffer_size: 12
|
|
|
|
result: ['foo', 'bar', 'car']
|
|
|
|
|
|
|
|
- cmdline: 'foo bar car'
|
|
|
|
argv_count_max: 2
|
|
|
|
error: 'too many args'
|
|
|
|
- cmdline: 'foo bar car'
|
|
|
|
buffer_size: 11
|
|
|
|
error: 'buffer overflow'
|
|
|
|
- cmdline: 'foo bar car'
|
|
|
|
argv_count_max: 2
|
|
|
|
buffer_size: 11
|
|
|
|
error: 'too many args'
|
|
|
|
|
|
|
|
- cmdline: '\"foo\" \"bar\" \"car\"'
|
|
|
|
argv_count_max: 3
|
|
|
|
result: ['foo', 'bar', 'car']
|
|
|
|
- cmdline: '\"foo\" \"bar\" \"car\"'
|
|
|
|
buffer_size: 12
|
|
|
|
result: ['foo', 'bar', 'car']
|
|
|
|
- cmdline: '\"foo\" \"bar\" \"car\"'
|
|
|
|
argv_count_max: 3
|
|
|
|
buffer_size: 12
|
|
|
|
result: ['foo', 'bar', 'car']
|
|
|
|
|
|
|
|
- cmdline: '\"foo\" \"bar\" \"car\"'
|
|
|
|
argv_count_max: 2
|
|
|
|
error: 'too many args'
|
|
|
|
- cmdline: '\"foo\" \"bar\" \"car\"'
|
|
|
|
buffer_size: 11
|
|
|
|
error: 'buffer overflow'
|
|
|
|
- cmdline: '\"foo\" \"bar\" \"car\"'
|
|
|
|
argv_count_max: 2
|
|
|
|
buffer_size: 11
|
|
|
|
error: 'too many args'
|
2022-06-07 22:51:45 -04:00
|
|
|
|
|
|
|
- cmdline: '\\ '
|
|
|
|
result: [' ']
|
|
|
|
- cmdline: '\"\\ \"'
|
|
|
|
result: [' ']
|
|
|
|
- cmdline: '\\\\'
|
|
|
|
result: ['\\']
|
|
|
|
- cmdline: '\"\\\\\"'
|
|
|
|
result: ['\\']
|
|
|
|
- cmdline: '\\\"'
|
|
|
|
result: ['\"']
|
|
|
|
- cmdline: '\"\\\"\"'
|
|
|
|
result: ['\"']
|
|
|
|
- cmdline: 'foo\\ '
|
|
|
|
result: ['foo ']
|
|
|
|
- cmdline: '\"foo\\ \"'
|
|
|
|
result: ['foo ']
|
|
|
|
- cmdline: 'foo\\\\'
|
|
|
|
result: ['foo\\']
|
|
|
|
- cmdline: '\"foo\\\\\"'
|
|
|
|
result: ['foo\\']
|
|
|
|
- cmdline: 'foo\\\"'
|
|
|
|
result: ['foo\"']
|
|
|
|
- cmdline: '\"foo\\\"\"'
|
|
|
|
result: ['foo\"']
|
|
|
|
- cmdline: '\\ foo'
|
|
|
|
result: [' foo']
|
|
|
|
- cmdline: '\"\\ foo\"'
|
|
|
|
result: [' foo']
|
|
|
|
- cmdline: '\\\\foo'
|
|
|
|
result: ['\\foo']
|
|
|
|
- cmdline: '\"\\\\foo\"'
|
|
|
|
result: ['\\foo']
|
|
|
|
- cmdline: '\\\"foo'
|
|
|
|
result: ['\"foo']
|
|
|
|
- cmdline: '\"\\\"foo\"'
|
|
|
|
result: ['\"foo']
|
|
|
|
- cmdline: '\\ foo\\ '
|
|
|
|
result: [' foo ']
|
|
|
|
- cmdline: '\"\\ foo\\ \"'
|
|
|
|
result: [' foo ']
|
|
|
|
- cmdline: '\\\\foo\\\\'
|
|
|
|
result: ['\\foo\\']
|
|
|
|
- cmdline: '\"\\\\foo\\\\\"'
|
|
|
|
result: ['\\foo\\']
|
|
|
|
- cmdline: '\\\"foo\\\"'
|
|
|
|
result: ['\"foo\"']
|
|
|
|
- cmdline: '\"\\\"foo\\\"\"'
|
|
|
|
result: ['\"foo\"']
|
|
|
|
- cmdline: 'foo\\ bar'
|
|
|
|
result: ['foo bar']
|
|
|
|
- cmdline: '\"foo\\ bar\"'
|
|
|
|
result: ['foo bar']
|
|
|
|
- cmdline: 'foo\\\\bar'
|
|
|
|
result: ['foo\\bar']
|
|
|
|
- cmdline: '\"foo\\\\bar\"'
|
|
|
|
result: ['foo\\bar']
|
|
|
|
- cmdline: 'foo\\\"bar'
|
|
|
|
result: ['foo\"bar']
|
|
|
|
- cmdline: '\"foo\\\"bar\"'
|
|
|
|
result: ['foo\"bar']
|
|
|
|
- cmdline: '\\ foo bar'
|
|
|
|
result: [' foo', 'bar']
|
|
|
|
- cmdline: '\"\\ foo\" bar'
|
|
|
|
result: [' foo', 'bar']
|
|
|
|
- cmdline: '\\\\foo bar'
|
|
|
|
result: ['\\foo', 'bar']
|
|
|
|
- cmdline: '\"\\\\foo\" bar'
|
|
|
|
result: ['\\foo', 'bar']
|
|
|
|
- cmdline: '\\\"foo bar'
|
|
|
|
result: ['\"foo', 'bar']
|
|
|
|
- cmdline: '\"\\\"foo\" bar'
|
|
|
|
result: ['\"foo', 'bar']
|
|
|
|
- cmdline: 'foo\\ bar'
|
|
|
|
result: ['foo ', 'bar']
|
|
|
|
- cmdline: '\"foo\\ \" bar'
|
|
|
|
result: ['foo ', 'bar']
|
|
|
|
- cmdline: 'foo\\\\ bar'
|
|
|
|
result: ['foo\\', 'bar']
|
|
|
|
- cmdline: '\"foo\\\\\" bar'
|
|
|
|
result: ['foo\\', 'bar']
|
|
|
|
- cmdline: 'foo\\\" bar'
|
|
|
|
result: ['foo\"', 'bar']
|
|
|
|
- cmdline: '\"foo\\\"\" bar'
|
|
|
|
result: ['foo\"', 'bar']
|
|
|
|
- cmdline: '\\ foo\\ bar'
|
|
|
|
result: [' foo ', 'bar']
|
|
|
|
- cmdline: '\"\\ foo\\ \" bar'
|
|
|
|
result: [' foo ', 'bar']
|
|
|
|
- cmdline: '\\\\foo\\\\ bar'
|
|
|
|
result: ['\\foo\\', 'bar']
|
|
|
|
- cmdline: '\"\\\\foo\\\\\" bar'
|
|
|
|
result: ['\\foo\\', 'bar']
|
|
|
|
- cmdline: '\\\"foo\\\" bar'
|
|
|
|
result: ['\"foo\"', 'bar']
|
|
|
|
- cmdline: '\"\\\"foo\\\"\" bar'
|
|
|
|
result: ['\"foo\"', 'bar']
|
|
|
|
- cmdline: 'foo \\ bar'
|
|
|
|
result: ['foo', ' bar']
|
|
|
|
- cmdline: 'foo \"\\ bar\"'
|
|
|
|
result: ['foo', ' bar']
|
|
|
|
- cmdline: 'foo \\\\bar'
|
|
|
|
result: ['foo', '\\bar']
|
|
|
|
- cmdline: 'foo \"\\\\bar\"'
|
|
|
|
result: ['foo', '\\bar']
|
|
|
|
- cmdline: 'foo \\\"bar'
|
|
|
|
result: ['foo', '\"bar']
|
|
|
|
- cmdline: 'foo \"\\\"bar\"'
|
|
|
|
result: ['foo', '\"bar']
|
|
|
|
- cmdline: 'foo bar\\ '
|
|
|
|
result: ['foo', 'bar ']
|
|
|
|
- cmdline: 'foo \"bar\\ \"'
|
|
|
|
result: ['foo', 'bar ']
|
|
|
|
- cmdline: 'foo bar\\\\'
|
|
|
|
result: ['foo', 'bar\\']
|
|
|
|
- cmdline: 'foo \"bar\\\\\"'
|
|
|
|
result: ['foo', 'bar\\']
|
|
|
|
- cmdline: 'foo bar\\\"'
|
|
|
|
result: ['foo', 'bar\"']
|
|
|
|
- cmdline: 'foo \"bar\\\"\"'
|
|
|
|
result: ['foo', 'bar\"']
|
|
|
|
- cmdline: 'foo \\ bar\\ '
|
|
|
|
result: ['foo', ' bar ']
|
|
|
|
- cmdline: 'foo \"\\ bar\\ \"'
|
|
|
|
result: ['foo', ' bar ']
|
|
|
|
- cmdline: 'foo \\\\bar\\\\'
|
|
|
|
result: ['foo', '\\bar\\']
|
|
|
|
- cmdline: 'foo \"\\\\bar\\\\\"'
|
|
|
|
result: ['foo', '\\bar\\']
|
|
|
|
- cmdline: 'foo \\\"bar\\\"'
|
|
|
|
result: ['foo', '\"bar\"']
|
|
|
|
- cmdline: 'foo \"\\\"bar\\\"\"'
|
|
|
|
result: ['foo', '\"bar\"']
|
2022-06-07 22:56:06 -04:00
|
|
|
|
|
|
|
- cmdline: 'foo\\ bar car'
|
|
|
|
result: ["foo bar", "car"]
|
|
|
|
- cmdline: '\"foo bar\" car'
|
|
|
|
result: ["foo bar", "car"]
|
|
|
|
- cmdline: '\"foo bar\" \"car\"'
|
|
|
|
result: ["foo bar", "car"]
|
|
|
|
- cmdline: 'foo bar\\ car'
|
|
|
|
result: ['foo', 'bar car']
|
|
|
|
- cmdline: 'foo \"bar car\"'
|
|
|
|
result: ['foo', 'bar car']
|
|
|
|
- cmdline: '\"foo\" \"bar car\"'
|
|
|
|
result: ['foo', 'bar car']
|