Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: run passes arguments to binary incorrectly #10761

Closed
bradfitz opened this issue May 8, 2015 · 3 comments
Closed

cmd/go: run passes arguments to binary incorrectly #10761

bradfitz opened this issue May 8, 2015 · 3 comments
Milestone

Comments

@bradfitz
Copy link
Contributor

bradfitz commented May 8, 2015

$ cat x.go
package main

import (
    "fmt"
    "os"
)

func main() {
    fmt.Printf("%q\n", os.Args)
}

$ go run x.go a b "c d"
["/var/folders/n7/gw0f1vrj0m5ffgwgyzbm2fwm001w6m/T/go-build004220194/command-line-arguments/_obj/exe/x" "a" "b" "c" "d"]

Note that c and d are split into two arguments.

Using go build + ./x a b "c d" works as expected, so the problem is with go run somewhere.

(noticed with @robpike and @randall77)

@bradfitz bradfitz added this to the Go1.5 milestone May 8, 2015
@odeke-em
Copy link
Member

odeke-em commented May 9, 2015

I don't know if this helps, but at least it was working right by ac61588 committed on Fri Dec 19 14:28:44 2014 -0500
screen shot 2015-05-08 at 6 48 13 pm

@robpike robpike self-assigned this May 9, 2015
@minux
Copy link
Member

minux commented May 9, 2015

Interesting. I can't reproduce this.

$ go run issue10761.go a b "c d"
["/var/folders/p6/9tyrs0yx74l6t96y2rsq07300000gn/T/go-build212843169/command-line arguments/_obj/exe/issue10761" "a" "b" "c d"]
$ go version
go version devel +82359d1 Sat May 9 02:58:50 2015 +0000 darwin/amd64

@bradfitz
Copy link
Contributor Author

bradfitz commented May 9, 2015

It's all my fault yet again.

My first mistake was in run.bash, fixed by https://go-review.googlesource.com/#/c/9892/.
My second mistake (the same mistake) was /home/bradfitz/bin/go (first in my $PATH for "go") which was:

$ cat ~/bin/go
#!/bin/sh
exec $GOROOT/bin/go $@

... which I forgot I even had.

I never knew about this bash/shell "$@" "feature" until today.

Sorry for the noise.

@bradfitz bradfitz closed this as completed May 9, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
@rsc rsc unassigned robpike Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants