Validate JSON for --jsonarg

Fixes #2572
This commit is contained in:
Mattias Wadman authored and Nico Williams committed 2023-07-05 16:30:14 -05:00
1 parent c077b95ba2
commit 95625c3fdb
2 files changed
+25 -2

No files matched your search

+13
View File
@@ -207,6 +207,19 @@ fi
echo '{"a":1,"b",' | $JQ --stream > /dev/null 2> $d/err
grep 'Objects must consist of key:value pairs' $d/err > /dev/null
## Regression test for issue #2572 assert when using --jsonargs and invalid JSON
$JQ -n --jsonargs null invalid && EC=$? || EC=$?
if [ "$EC" -ne 2 ]; then
echo "--jsonargs exited with wrong exit code, expected 2 got $EC" 1>&2
exit 1
fi
# this tests the args_done code path "--"
$JQ -n --jsonargs null -- invalid && EC=$? || EC=$?
if [ "$EC" -ne 2 ]; then
echo "--jsonargs exited with wrong exit code, expected 2 got $EC" 1>&2
exit 1
fi
## Fuzz parser
## XXX With a $(urandom) builtin we could move this test into tests/all.test