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/compile: usage prints to stdout instead of stderr #23234

Closed
jfcg opened this issue Dec 24, 2017 · 8 comments
Closed

cmd/compile: usage prints to stdout instead of stderr #23234

jfcg opened this issue Dec 24, 2017 · 8 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jfcg
Copy link

jfcg commented Dec 24, 2017

apparently go tool link uses stderr instead of stdout..

What version of Go are you using (go version)?

go1.9.2 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

linux / amd64

What did you do?

go tool link --help | grep -i debug

What did you expect to see?

-debugtramp int
debug trampolines

What did you see instead?

the whole list of link options

working example

go tool compile --help | grep -i debug

@cznic
Copy link
Contributor

cznic commented Dec 24, 2017

use |&.

@jfcg
Copy link
Author

jfcg commented Dec 24, 2017

I already know that, but "tools behave differently" is the point

@mvdan
Copy link
Member

mvdan commented Dec 24, 2017

All the tools print help messages to stderr. That is consistent.

@jfcg
Copy link
Author

jfcg commented Dec 24, 2017

Have you checked:
go tool compile --help | grep -i debug
go tool link --help | grep -i debug
are you sure?

@gbbr
Copy link
Member

gbbr commented Dec 24, 2017

@mvdan is right, this is standard for all command line tools and the flag package when outputting usage information.

Usage statements should by default be written in standard error output. You may check this article’s secrion “Where” for more information.

Closing. Merry Christmas! 🎄🎅🎁

@gbbr gbbr closed this as completed Dec 24, 2017
@gbbr gbbr changed the title cant grep go tool link --help cmd/go: cant grep go tool link --help Dec 24, 2017
@mvdan
Copy link
Member

mvdan commented Dec 24, 2017

I think @jfcg has a point here, though - all the tools use stderr for usage messages, yet go tool compile seems to use stdout:

$ go tool compile
[usage text]
$ go tool compile >/dev/null

Let's keep this issue open for that inconsistency.

@mvdan mvdan reopened this Dec 24, 2017
@mvdan mvdan changed the title cmd/go: cant grep go tool link --help cmd/compile: usage prints to stdout instead of stderr Dec 24, 2017
@mvdan
Copy link
Member

mvdan commented Dec 24, 2017

I cannot see a good reason why it would, and it seems like it has always printed to stdout since it was created in 2015 from all the separate compilers - will give this a go for 1.11.

@mvdan mvdan self-assigned this Dec 24, 2017
@mvdan mvdan added this to the Go1.11 milestone Dec 24, 2017
@mvdan mvdan added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 24, 2017
@gopherbot
Copy link

Change https://golang.org/cl/85418 mentions this issue: cmd/compile: print usage to stderr for consistency

@golang golang locked and limited conversation to collaborators Feb 13, 2019
@rsc rsc unassigned mvdan Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants