-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Choose line endings #92
Comments
jq doesn't mangle line endings on its own, it just tells the C library to print '\n'. The Cygwin C library seems to interpret this as "print CRLF". I think (although it's been a while since I've used Cygwin) that you can configure cygwin to not do this. If all else fails, we can add an option to get jq to open files in binary mode. This seems like the wrong thing to do, though - I think you should be able to fix this by modifying your cygwin config. That would fix it for programs other than jq as well. |
This definitely seems to be Cygwin's problem, not jq's. There's a bunch of ways around this on http://cygwin.com/cygwin-ug-net/using-textbinary.html |
Or pipe into
|
http://cygwin.com/cygwin-ug-net/using-textbinary.html says that
but I'm seeing CRLF in piped output in MinGW64, so there may be something else to consider here. |
Hi @stedolan, I think this issue is still unresolved. I think there is a confusion between the line endings that are used in raw mode and outside raw mode. For example, if you type the following into the Command Prompt
the string between the brackets must not contain a carriage return under any platform. There is a second issue here, which is that this command produces an extra trailing newline. These are significant issues because it is extremely important for the user to be able to perform a perfect decoding of the contents of JSON strings. Any transformations can mess things up. However, the way things are currently, I have to resort to Python for this task, because with |
This is really a problem when using the stand-alone jq-winXX.exe under cmd (batch scripts) where Unix tr(1) is not available. This is almost killing jq for me. |
We cannot use |
"tr -d '\r'" is used to avoid Windows errors, reference: jqlang/jq#92
If anyone landed here and had the same problem, I solved it by using the |
On the Windows version at least output lines are ended with carriage return newline
CRLF
, which is of course the Windows default.However this can cause havoc for Windows users with Cygwin or MinGW, as those systems rely on lines to end with newline
LF
only.Perhaps a command line switch could be made to enable
LF
line endings. As a workaroud, you can use:The text was updated successfully, but these errors were encountered: