diff options
Diffstat (limited to 'lib/os/exec/exec_test.go')
| -rw-r--r-- | lib/os/exec/exec_test.go | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/os/exec/exec_test.go b/lib/os/exec/exec_test.go index 38e089d0..d0da6e48 100644 --- a/lib/os/exec/exec_test.go +++ b/lib/os/exec/exec_test.go @@ -42,17 +42,33 @@ func TestParseCommandArg(t *testing.T) { expCmd: `a`, expArgs: []string{`b'c`}, }, { - in: `a\ b c\ d`, - expCmd: "a b", + in: `a\ b c\ d`, + expCmd: "a b", expArgs: []string{"c d"}, }, { - in: `a\\ b c\\ d`, - expCmd: `a\`, + in: `a\\ b c\\ d`, + expCmd: `a\`, expArgs: []string{"b", `c\`, "d"}, }, { - in: `a\\\ b c\\\ d`, - expCmd: `a\ b`, + in: `a\\\ b c\\\ d`, + expCmd: `a\ b`, expArgs: []string{`c\ d`}, + }, { + in: `sh -c "echo \"a\""`, + expCmd: "sh", + expArgs: []string{`-c`, `echo "a"`}, + }, { + in: `sh -c "sh -c \"echo 'a\x'\""`, + expCmd: "sh", + expArgs: []string{`-c`, `sh -c "echo 'a\x'"`}, + }, { + in: `sh -c "sh -c \"echo 'a'\'''\""`, + expCmd: "sh", + expArgs: []string{`-c`, `sh -c "echo 'a'\'''"`}, + }, { + in: `sh -c "sh -c \"echo 'a\\\"'\""`, + expCmd: "sh", + expArgs: []string{`-c`, `sh -c "echo 'a\"'"`}, }} for _, c := range cases { |
