jzelinskie / faq

Format Agnostic jQ -- process various formats with libjq
Apache License 2.0
439 stars 14 forks source link

pretty print breaks raw output #71

Closed endorama closed 4 years ago

endorama commented 4 years ago

Hello, I started using faq but I found what I think is an issue.

When using raw output mode, faq breaks trying to pretty encode the output. I would have expected that raw output would override all enhancements to the output, but it does not seem the case.

How to reproduce:

$ echo '"hello world"' | faq --input-format=json -r "."
Error: failed to encode as pretty: invalid character 'h' looking for beginning of value

Adding --pretty-output=false to the above command makes it work:

$ echo '"hello world"' | faq --input-format=json -r --pretty-output=false "."
hello world

Is this the expected --raw-output behaviour?

jzelinskie commented 4 years ago

This is definitely non-ideal behavior.

IIRC the pretty-print flag for jq is implicitly set based on other flags, so that this cannot happen (pretty can never be enabled if raw is enabled).

This seems like an easy enough fix, just add some validation to override the pretty flag when someone sets raw.

endorama commented 4 years ago

This seems like an easy enough fix, just add some validation to override the pretty flag when someone sets raw

Happy to try to fix it, I'll give a go by next week.

jzelinskie commented 4 years ago

Oh, no pressure! Don't feel obligated just because you made the issue.

jzelinskie commented 4 years ago

Fixed in #73