1
0
mirror of https://github.com/golang/go synced 2024-10-01 01:48:32 -06:00

go.tools/playground: parse shebang correctly

Fixes golang/go#7321.

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/63560043
This commit is contained in:
Francesc Campoy 2014-02-18 09:44:12 -08:00
parent 0b0cd8b22c
commit ca8198c132

View File

@ -165,6 +165,7 @@ func (p *process) Kill() {
// shebang looks for a shebang ('#!') at the beginning of the passed string.
// If found, it returns the path and args after the shebang.
// args includes the command as args[0].
func shebang(body string) (path string, args []string) {
body = strings.TrimSpace(body)
if !strings.HasPrefix(body, "#!") {
@ -174,7 +175,7 @@ func shebang(body string) (path string, args []string) {
body = body[:i]
}
fs := strings.Fields(body[2:])
return fs[0], fs[1:]
return fs[0], fs
}
// startProcess starts a given program given its path and passing the given body