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

it can be easy to miss the stderr when forgetting to use -g with -a when processing a stream #114

Open
trentm opened this issue Mar 9, 2017 · 1 comment

Comments

@trentm
Copy link
Owner

trentm commented Mar 9, 2017

For example:

[16:23:31 trentm@danger0:~/tm/json (master)]
$ cat foo.json
{"foo":"bar"}
{"foo":"bar"}
{asdf}
{"foo":"bar"}
{qwer}
{"foo":"bar"}
[16:23:40 trentm@danger0:~/tm/json (master)]
$ cat foo.json | json -a foo
json: error: input is not JSON: Syntax error at line 2, column 1:
        {"foo":"bar"}
        ^
{"foo":"bar"}
{"foo":"bar"}
{asdf}
{"foo":"bar"}
{qwer}
{"foo":"bar"}

json here will print the error to stderr, and then the full content of the file to stdout. If the file is large, it is way too easy to miss the error that can be the hint to know to use -g.

One idea is to move that stderr to the end of the output to make it harder to miss.

Other ideas welcome too.

@trentm
Copy link
Owner Author

trentm commented Mar 9, 2017

@davepacheco mentioned that if we do the work to allow json to skip non-JSON lines in streaming mode, it "would be nice if it emitted errors for each bad line, but you still got all the other output".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant