-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: go run always returns exit code 1, no matter what the real exit code was #13440
Comments
In the general case we can't recreate the right exit status, but I suppose we could pass along an ordinary exit code. |
I think the exit code would be enough, just to be able to use |
CL https://golang.org/cl/18271 mentions this issue. |
Not for Go 1.6. |
From code review:
Fair enough, let me try again: What if it crashed due to a signal? The real question is whether 'go run x.go' is supposed to be just an interpreter for Go programs, like 'python x.py' or whether it is a tool that runs a subprocess and reports the results itself, like make. To date, the answer has been the latter. So it's not obvious the behavior is wrong, unless 'go run' is supposed to be some kind of interactive go command, which we've said in the past it is not.
(Make happens to use 2 instead of 1, but it's always 2 on my system.)
|
I agree with Russ for the reasons he stated. An exit code is a single-dimensional value. When doing However, IMO, if one cares about the exact exit code of the program that is executed, they need to build it and execute it themselves. |
I think this is effectively closed. |
I updated the CL to fix only windows and unix. Still wrong? |
@shurcooL how about to add new flag to return status code (non-1) of the exit code from |
Please, no more flags. Go run is for toy programs, if you have a serious On Wed, 11 May 2016, 13:26 mattn, notifications@github.com wrote:
|
@davecheney So do you think https://github.com/sno6/gommand this should do |
My advice that Go run is a toy, and adding more features to it to make it On Wed, 11 May 2016, 13:32 mattn, notifications@github.com wrote:
|
Okay, agreed. Thanks. |
What version of Go are you using (go version)?
What operating system and processor architecture are you using?
Mac OS X 10.11.1
What did you do?
Saved this Go program into
main.go
:And then ran
go run main.go
:What did you expect to see?
$ echo $?
should be3
instead of1
What did you see instead?
The exit code reported by
$ echo $?
is always1
if the program exits with a non zero exit code.If you compile the example with
$ go build -o gotest
it returns the expected exit code:The text was updated successfully, but these errors were encountered: