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

Comments

Projects
None yet
5 participants
@jfcg
Copy link

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

This comment has been minimized.

Copy link
Contributor

commented Dec 24, 2017

use |&.

@jfcg

This comment has been minimized.

Copy link
Author

commented Dec 24, 2017

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

@mvdan

This comment has been minimized.

Copy link
Member

commented Dec 24, 2017

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

@jfcg

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Member

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 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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

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 label Dec 24, 2017

@gopherbot

This comment has been minimized.

Copy link

commented Dec 24, 2017

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

@gopherbot gopherbot closed this in 7ddd467 Feb 13, 2018

@golang golang locked and limited conversation to collaborators Feb 13, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.