Make jq --raw-output --unbuffered work
--unbuffered was only affecting the normal output case, not the --raw-output case. Make the two of them play together. This also makes sure that the output is flushed *after* printing the newline, so a consumer doesn't lag a line behind.
This commit is contained in:
1 parent
15faf9dc3b
commit
36e495da1e
3 files changed
+3
-5
No files matched your search
@@ -89,7 +89,6 @@ static int process(jq_state *jq, jv value, int flags) {
|
||||
if (options & ASCII_OUTPUT) dumpopts |= JV_PRINT_ASCII;
|
||||
if (options & COLOUR_OUTPUT) dumpopts |= JV_PRINT_COLOUR;
|
||||
if (options & NO_COLOUR_OUTPUT) dumpopts &= ~JV_PRINT_COLOUR;
|
||||
if (options & UNBUFFERED_OUTPUT) dumpopts |= JV_PRINT_UNBUFFERED;
|
||||
if (jv_get_kind(result) == JV_KIND_FALSE || jv_get_kind(result) == JV_KIND_NULL)
|
||||
ret = 11;
|
||||
else
|
||||
@@ -97,6 +96,8 @@ static int process(jq_state *jq, jv value, int flags) {
|
||||
jv_dump(result, dumpopts);
|
||||
}
|
||||
printf("\n");
|
||||
if (options & UNBUFFERED_OUTPUT)
|
||||
fflush(stdout);
|
||||
}
|
||||
jv_free(result);
|
||||
return ret;
|
||||
|
||||
Reference in new issue
Block a user