diff options
| author | Shulhan <ms@kilabit.info> | 2021-08-12 23:39:53 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-08-13 13:32:57 +0700 |
| commit | 1adcb7901dc62ef288cf82f504f8fae30068b21b (patch) | |
| tree | 5248ac3f284c5102bff044e6e195bf9d4691be76 /lib/os/exec/exec_test.go | |
| parent | 4aa4b560eb683d742dc7ff3136089c73f6a0023d (diff) | |
| download | pakakeh.go-1adcb7901dc62ef288cf82f504f8fae30068b21b.tar.xz | |
os/exec: include the quoted characters when ParseCommandArgs
Previously, if we pass `a "b c"` to ParseCommanArgs, it will return
`a` as command and `b c` in args.
Now, it will return `"b c"` in args with double quotes.
Diffstat (limited to 'lib/os/exec/exec_test.go')
| -rw-r--r-- | lib/os/exec/exec_test.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/os/exec/exec_test.go b/lib/os/exec/exec_test.go index 38e089d0..8c8286bc 100644 --- a/lib/os/exec/exec_test.go +++ b/lib/os/exec/exec_test.go @@ -10,7 +10,7 @@ import ( "github.com/shuLhan/share/lib/test" ) -func TestParseCommandArg(t *testing.T) { +func TestParseCommandArgs(t *testing.T) { cases := []struct { in string expCmd string @@ -24,34 +24,34 @@ func TestParseCommandArg(t *testing.T) { }, { in: `a "b c"`, expCmd: `a`, - expArgs: []string{`b c`}, + expArgs: []string{`"b c"`}, }, { in: `a "b'c"`, expCmd: `a`, - expArgs: []string{`b'c`}, + expArgs: []string{`"b'c"`}, }, { in: `'a "b'c"`, - expCmd: `a "b`, + expCmd: `'a "b'`, expArgs: []string{`c`}, }, { in: "a `b c`", expCmd: `a`, - expArgs: []string{`b c`}, + expArgs: []string{"`b c`"}, }, { in: "a `b'c`", expCmd: `a`, - expArgs: []string{`b'c`}, + 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`}, }} |
