-
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
Reduce over raw files - EOF doesn't terminate inputs
#2374
Comments
This is the behaviour on both 1.5 and 1.6, afaict. |
Another data point - this weirdness on the last line of a file also affects
|
|
Please note that, for better or worse, jq behaves just like
In other words, stringing together file names on the jq command line is more akin to running
yields the single number: 12 So for jq 1.3 through jq 1.6, this perhaps undesirable behavior is, for most intents and purposes, a "feature" given the "backwards compatibility" constraint for X.Y versions. |
@pkoppstein Thanks for the clarification. So my proposed change in #2375 does actually break backwards compatibility here, as it now breaks at EOF when processing raw input:
|
Another related problem is that normally $ jq . /dev/stdin /dev/fd/3 <<<$'\ufeff'1 3<<<$'\ufeff'2
1
jq: parse error: Invalid numeric literal at line 3, column 0 |
GitHub needs more emoticons, so we can express horror, for example. |
This looks like a bug, but perhaps I'm just missing something obvious. I'm trying to combine multiple raw (non-JSON) files and embed them in a JSON object. These files are ultimately found by a glob, so I don't think I can use
--rawfile
without extensive bash machinery on top; instead I need to reduce them with-R
to read each line, and recombine them based oninput_filename
.This almost works, but the last line of each file is inserted into the wrong list:
It took me a while to work out, but this is because there's no bare newline at the end of my files. If I add that to the test files, it works correctly. ie, if I rewrite
foo.txt
from:to
But I can't guarantee that the real files will be terminated by an empty line. Surely
inputs
should 'split' at EOF, as well as each newline? It clearly does for the final file, since we get a final entry for the last line there, so why does it combine the entries from earlier files, across EOF marks?Just to confirm, this also happens with direct invocations of
input
:The text was updated successfully, but these errors were encountered: