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

Report better error when single-quotes in program #538

Closed
dandv opened this issue Aug 6, 2014 · 6 comments
Closed

Report better error when single-quotes in program #538

dandv opened this issue Aug 6, 2014 · 6 comments

Comments

@dandv
Copy link

dandv commented Aug 6, 2014

I've spend over 10 minutes trying to simply pretty-print a json file on Windows. This really shouldn't be that hard, but it is because classic conventions are violated:

type file.json | jq '.'
jq '.' < file.json

both fail with a cryptic error message,

error: syntax error, unexpected INVALID_CHARACTER, expecting $end
'.'1 compile error                                               

See #392 (comment) for details.

@nicowilliams
Copy link
Contributor

@dandv The problem is the shell, not jq. The problem here is that the shell doesn't handle single quotes like a Unix shell: it passes the single quotes to jq, and since single quotes are not a normal part of a jq program, you get an error. I think we could add some rules to the parser to produce an error message that might help the user understand.

Anyways, jq . (no single quotes) works on Windows.

@nicowilliams nicowilliams added this to the 1.5 release milestone Aug 6, 2014
@nicowilliams nicowilliams changed the title Incredibly counter-intuitive to get started on Windows Report better error when single-quotes in program Aug 6, 2014
@nicowilliams
Copy link
Contributor

If you don't mind I changed the issue title as I want to use this as the vehicle for the improvement at hand.

@nicowilliams
Copy link
Contributor

And, actually, I think we should probably always print a message about shell quoting when the error involves unexpected INVALID_CHARACTER, expecting $end.

@nicowilliams
Copy link
Contributor

And you're right, we could probably use a larger section on the shells.

@nicowilliams
Copy link
Contributor

The docs do have a note about invoking jq on Windows, right in the "Invoking jq" section. The "Note:" is not loud enough though :(

@dandv
Copy link
Author

dandv commented Aug 6, 2014

Thanks @nicowilliams, omitting the quotes worked. I should've tried double quotes too, which also works.

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

No branches or pull requests

3 participants