jq 1.7, released on September 6, 2023, adds --raw-output0 for shell jobs that need to pass JSON strings to another program without treating embedded newlines as record boundaries. The option puts a NUL byte after each output instead of a newline. It is an explicit choice, not a new default, and the receiving program must understand the same separator. Upgrading jq alone does not change a script's output format. [S1][S2][S5]

This matters when a JSON field contains more than one line. The existing --raw-output, or -r, option writes string results without JSON quotation marks. If the string itself contains a newline, a consumer that treats each line as a separate record can split that value. The new flag separates the end of a value from the line breaks inside it. The release notes demonstrate passing strings containing spaces and newlines through xargs -0, which reads NUL-separated items. [S1][S2][S5]

Changing the producer is only half the job. Replacing -r with --raw-output0 does not make a line-oriented reader understand NUL-separated records. Nor is --join-output, or -j, a substitute: the jq 1.7 manual says it removes the newline after each output, rather than replacing it with a separator. A job passing several values onward needs to preserve their boundaries, not remove them. [S1][S2][S5]

NUL itself remains a problem for raw strings. The manual says jq returns a nonzero exit code if an output value contains NUL, and the release notes show that rejection. In the ordinary raw-string path, without --ascii-output, jq 1.7 checks for NUL before writing the string. It reports an error rather than insert an ambiguous separator into the value. [S1][S2][S4][S5]

An error does not erase earlier output. The released implementation writes each successful result as it iterates, so a later string containing NUL can fail after earlier results have been written. For a job that must validate an entire list before acting, stage jq's output in a temporary file and check jq's exit status before passing it to the consumer—but do not treat one successful final status as proof that every input in a multi-input stream succeeded. jq 1.7's ordinary input loop replaces the prior status with each later input's result. A consumer connected directly to the output may start work before jq finishes. [S2][S4]

Source documents

  1. jq 1.7 GitHub releasehttps://api.github.com/repos/jqlang/jq/releases/tags/jq-1.7
  2. jq 1.7 manual sourcehttps://raw.githubusercontent.com/jqlang/jq/jq-1.7/docs/content/manual/manual.yml
  3. jq 1.7 command-line implementationhttps://raw.githubusercontent.com/jqlang/jq/jq-1.7/src/main.c
  4. jq 1.7 tagged NEWS.md release noteshttps://raw.githubusercontent.com/jqlang/jq/jq-1.7/NEWS.md