Fix exit code on JSON parse error
This PR fixes #2146. The exit code 4, which jq 1.6 emits on invalid input, is used to indicate no valid result for `--exit-status` option. It's better to be able to distinguish no valid result and JSON parse error. I think 5 is the only appropriate exit code considering the existing exit codes of jq.
**Describe the bug**
Prior to commit 6d3d2750, a syntax error in the JSON input would cause a nonzero return code. After this change, the error code is zero.

It is not clear to me from the description and linked issues #1139 and #1142 whether this is intentional or not, but in any case I find it counter-intuitive to require a '-e' option for this.

**To Reproduce**
``` echo foobar | jq .```

**Expected behavior**
nonzero return code in case of syntax errors in JSON input (4 or something else, I don't really care, as long as it is not '0').

**Environment (please complete the following information):**
Tested on CentOS 7, Gentoo
OK on jq 1.4, 1.5, 1.6
Broken since commit 6d3d2750 (bisected)

Commit 6d3d2750 now requires '-e' to detect syntax error in input
diff --git a/src/main.c b/src/main.c
index 45f61d0bba..ebe0e9d971 100644
--- a/src/main.c
+++ b/src/main.c
@@ -688,12 +688,12 @@ int main(int argc, char* argv[]) {
       // Parse error
       jv msg = jv_invalid_get_msg(value);
       if (!(options & SEQ)) {
-        // --seq -> errors are not fatal
-        ret = JQ_OK_NO_OUTPUT;
+        ret = JQ_ERROR_UNKNOWN;
         fprintf(stderr, "jq: parse error: %s\n", jv_string_value(msg));
         jv_free(msg);
         break;
       }
+      // --seq -> errors are not fatal
       fprintf(stderr, "jq: ignoring parse error: %s\n", jv_string_value(msg));
       jv_free(msg);
     }

diff --git a/tests/shtest b/tests/shtest
index 4cffb1f821..6594a906db 100755
--- a/tests/shtest
+++ b/tests/shtest
@@ -143,6 +143,15 @@ if $VALGRIND $Q $JQ -e . $d/input; then
   exit 2
 fi
 
+# Regression test for #2146
+if echo "foobar" | $JQ .; then
+  printf 'Issue #2146 is back?\n' 1>&2
+  exit 1
+elif [ $? -ne 5 ]; then
+  echo "Invalid input had wrong error code" 1>&2
+  exit 1
+fi
+
 # Regression test for #1534
 echo "[1,2,3,4]" > $d/expected
 printf "[1,2][3,4]" | $JQ -cs add > $d/out 2>&1
@@ -204,7 +213,7 @@ else
 fi
 
 ## Regression test for issue #2378 assert when stream parse broken object pair
-echo '{"a":1,"b",' | $JQ --stream  > /dev/null 2> $d/err
+echo '{"a":1,"b",' | $JQ --stream  > /dev/null 2> $d/err || true
 grep 'Objects must consist of key:value pairs' $d/err > /dev/null
 
 ## Fuzz parser

{"tests/shtest": {"run": "PASS", "test": "FAIL", "fix": "PASS"}}
{"test_options": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "regset": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "callback_each_match": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/utf8test": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "names": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test_utf8": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "simple": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/base64test": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "echo": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/mantest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "testc": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test_syntax": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test_back": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "bug_fix": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/jqtest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "scan": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/onigtest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "encode": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "callout": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "listcap": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/optionaltest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "user_property": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test_regset": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "testcu": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "count": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "syntax": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "sql": {"run": "PASS", "test": "PASS", "fix": "PASS"}}
{"tests/shtest": {"run": "PASS", "test": "FAIL", "fix": "PASS"}}
{"passed_count": 28, "failed_count": 0, "skipped_count": 0, "passed_tests": ["regset", "callback_each_match", "names", "test_utf8", "testc", "test_syntax", "sql", "bug_fix", "scan", "tests/onigtest", "encode", "listcap", "tests/optionaltest", "test_regset", "testcu", "count", "syntax", "test_options", "tests/utf8test", "simple", "tests/base64test", "tests/mantest", "test_back", "tests/jqtest", "tests/shtest", "callout", "user_property", "echo"], "failed_tests": [], "skipped_tests": []}
{"passed_count": 27, "failed_count": 1, "skipped_count": 0, "passed_tests": ["regset", "callback_each_match", "names", "test_utf8", "testc", "test_syntax", "sql", "bug_fix", "scan", "tests/onigtest", "encode", "listcap", "tests/optionaltest", "test_regset", "testcu", "count", "syntax", "test_options", "tests/utf8test", "simple", "tests/base64test", "tests/mantest", "test_back", "tests/jqtest", "callout", "user_property", "echo"], "failed_tests": ["tests/shtest"], "skipped_tests": []}
{"passed_count": 28, "failed_count": 0, "skipped_count": 0, "passed_tests": ["regset", "callback_each_match", "names", "test_utf8", "testc", "test_syntax", "sql", "bug_fix", "scan", "tests/onigtest", "encode", "listcap", "tests/optionaltest", "test_regset", "testcu", "count", "syntax", "test_options", "tests/utf8test", "simple", "tests/base64test", "tests/mantest", "test_back", "tests/jqtest", "tests/shtest", "callout", "user_property", "echo"], "failed_tests": [], "skipped_tests": []}