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

stdout instead of stderr #112

Closed
andrewdeandrade opened this issue Apr 13, 2015 · 8 comments

Comments

@andrewdeandrade
Copy link

commented Apr 13, 2015

Currently standard uses stderr for all output. This means that if you want to pipe standard, you need to redirect stderr to stdout with 2>&1 >/dev/null.

All lint errors should instead be printed to stdout so unix pipes work.

The general semantics of stdout is "content I'm interested in if I'm running this program" and stderr is "any content that is not related to the functionality of this program". i.e. these lines are appropriate for stderr:
https://github.com/feross/standard/blob/master/bin/cmd.js#L89
https://github.com/feross/standard/blob/master/bin/cmd.js#L108

@Flet

This comment has been minimized.

Copy link
Member

commented Apr 13, 2015

Some previous discussion on this is in #21.
@mafintosh's comment is relevant:

i think it should keep printing to stderr since its normal to do stuff like standard && tape test.js. otherwise it would mess up a tap parser (like npm test | tap-spec)

you can always just run

standard 2>&1 | grep variable

And FAQ on this:
https://github.com/feross/standard/blob/master/README.md#why-cant-i-pipe-standard-to-other-tools

@Flet

This comment has been minimized.

Copy link
Member

commented Apr 13, 2015

The previous thread on this sort of died off as no one was complaining about it. Perhaps this needs to be revisited?

@andrewdeandrade

This comment has been minimized.

Copy link
Author

commented Apr 13, 2015

The tap-parser issue is easy to solve, just print every line prefixed by #.

Alternatively, would you accept pull-requests for different formatters:

  • stylish
  • json
  • checkstyle

The only reason I suggest revisiting this is to follow standard unix convention**
http://www.jstorimer.com/blogs/workingwithcode/7766119-when-to-use-stderr-instead-of-stdout

(** which means that output on stderr should be prefixed with standard:)

@feross

This comment has been minimized.

Copy link
Member

commented Apr 14, 2015

@malandrew Thanks for the link about how stdout and stderr are supposed to work in unix programs. Very handy - I learned a few things.

I don't want to solve this by introducing multiple formatters - that's a slippery slope...

Let's just print the lint errors to stdout. I just tested tap-spec and it seems to ignore non-TAP output, so I don't think this will cause any problems for @mafintosh's use case.

There's one case where we'll continue printing the lint errors to stderr, and that's for standard --stdin --format. This command formats code on stdin and prints it to stdout, so any remaining lint errors need to go to stderr.

@mafintosh

This comment has been minimized.

Copy link
Contributor

commented Apr 14, 2015

@feross i don't feel strongly about printing to stderr/stdout and since tap-spec still works 👍 from me

feross added a commit that referenced this issue Apr 14, 2015

@feross

This comment has been minimized.

Copy link
Member

commented Apr 14, 2015

Made a PR for this: #113 Please share feedback.

feross added a commit that referenced this issue Apr 14, 2015

@Flet

This comment has been minimized.

Copy link
Member

commented Apr 14, 2015

Does not change format behavior. Cool. 👍

@feross feross closed this in #113 Apr 14, 2015

@feross

This comment has been minimized.

Copy link
Member

commented Apr 14, 2015

Released as 3.6.0.

andrewdeandrade added a commit to uber/standard that referenced this issue Apr 14, 2015

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018

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