mattn/go-shellwords

Backtick "eats" all runes until isSpace

andresvia opened this issue · 1 comments

Hi @mattn , I found a thing while trying to use go-shellwords.

go test -v 
=== RUN   ExampleShellwords
--- FAIL: ExampleShellwords (0.02s)
got:
["-flag=val0" "val1" "-flag=val2"]
want:
["-flag=val0" "-flag=val1" "-flag=val2"]
FAIL
exit status 1
FAIL	testsw	0.041s
cat testsw_test.go 
package testsw

import (
	"fmt"
	"github.com/mattn/go-shellwords"
)

func ExampleShellwords() {
	parser := shellwords.NewParser()
	parser.ParseBacktick = true
	args, err := parser.Parse("-flag=val0 -flag=`cat testdata/flag-val.txt` -flag=val2")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%q\n", args)
	// Output:
	// ["-flag=val0" "-flag=val1" "-flag=val2"]
}
cat go.mod 
module testsw

go 1.12

require github.com/mattn/go-shellwords v1.0.5
cat testdata/flag-val.txt 
val1
mattn commented

Thanks your report. Addressed in #26