Skip to content

panic on > redirection operator #14

@gromnitsky

Description

@gromnitsky
$ cat shellparse.go
package main
import ("github.com/mattn/go-shellwords"; "fmt")

func main() {
	args, _ := shellwords.Parse("a > b")
	fmt.Println(args)
}

yields in

$ go run shellparse.go 
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/mattn/go-shellwords.(*Parser).Parse(0xc420051ef8, 0x4f6e67, 0x5, 0x0, 0x0, 0xc420051f01, 0xc42000e230, 0xc420051f10)
        /home/alex/.go/src/github.com/mattn/go-shellwords/shellwords.go:143 +0xdff
github.com/mattn/go-shellwords.Parse(0x4f6e67, 0x5, 0x403d8c, 0xc42001c0b8, 0x0, 0xc420051f68, 0x4bb063)
        /home/alex/.go/src/github.com/mattn/go-shellwords/shellwords.go:177 +0x72
main.main()
        /home/alex/lib/software/example/go/src/my/hello/shellparse.go:5 +0x3a
exit status 2
$ go version
go version go1.10.2 linux/amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions