From ca8198c1320730270b4582ffd537ab2ab5079121 Mon Sep 17 00:00:00 2001 From: Francesc Campoy Date: Tue, 18 Feb 2014 09:44:12 -0800 Subject: [PATCH] go.tools/playground: parse shebang correctly Fixes golang/go#7321. LGTM=adg R=adg CC=golang-codereviews https://golang.org/cl/63560043 --- playground/socket/socket.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/playground/socket/socket.go b/playground/socket/socket.go index b8bde032..e5672435 100644 --- a/playground/socket/socket.go +++ b/playground/socket/socket.go @@ -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