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.
This commit is contained in:
Huang-404-Q authored and GitHub committed 2026-10-24 15:19:14 +09:00
1 parent da4da65c0c
commit bd56a74562
2 files changed
+9 -8

No files matched your search

+1 -1
View File
@@ -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