mirror of
https://github.com/golang/go
synced 2024-11-18 18:44:42 -07: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:
parent
0b0cd8b22c
commit
ca8198c132
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user