@ 261102.1

261024.3 · bd56a745624a5246fac7fe80d11a9cd6fb361ddb

Fix halt_error adding a newline to non-string output (#3694)

The manual says halt_error prints its input with no decoration, not even a newline, but non-string values such as {"a":"xyz"} were printed with a trailing newline.

Dump non-string values to JSON and print them the same way as strings, so {"a":"xyz"} | halt_error(1) now writes exactly {"a":"xyz"} to stderr.

reading declarations

Changes to tests/shtest. All files

tests/shtest

@@ -566,7 +566,7 @@ if [ "$($VALGRIND $Q $JQ -n '"x\u0000y\u0000z" | halt_error(1)' 2>&1 | tr '\0' '     echo "jq halt_error(1) had unexpected output" 1>&2     exit 1 fi-if [ "$($VALGRIND $Q $JQ -n '{"a":"xyz"} | halt_error(1)' 2>&1)" != '{"a":"xyz"}' ]; then+if [ "$($VALGRIND $Q $JQ -n '{"a":"xyz"} | halt_error(1)' 2>&1 || echo "z")" != '{"a":"xyz"}z' ]; then     echo "jq halt_error(1) had unexpected output" 1>&2     exit 1 fi