fix handling of -0 (#2235)

This commit is contained in:
Anthony Sottile authored and GitHub committed 2023-06-06 20:19:43 +09:00
1 parent b8816caf0a
commit 6c5c8f2115
2 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -105,7 +105,7 @@ static void die() {
static int isoptish(const char* text) { static int isoptish(const char* text) {
return text[0] == '-' && (text[1] == '-' || isalpha(text[1])); return text[0] == '-' && (text[1] == '-' || isalpha(text[1]) || text[1] == '0');
} }
static int isoption(const char* text, char shortopt, const char* longopt, size_t *short_opts) { static int isoption(const char* text, char shortopt, const char* longopt, size_t *short_opts) {
+6
View File
@@ -150,6 +150,12 @@ cmp $d/out $d/expected
printf "[1,2][3,4]\n" | $JQ -cs add > $d/out 2>&1 printf "[1,2][3,4]\n" | $JQ -cs add > $d/out 2>&1
cmp $d/out $d/expected cmp $d/out $d/expected
# Regression test for -0 / --nul-output
printf "a\0b\0" > $d/expected
printf '["a", "b"]' | $JQ -0 .[] > $d/out 2>&1
cmp $d/out $d/expected
printf '["a", "b"]' | $JQ --nul-output .[] > $d/out 2>&1
cmp $d/out $d/expected
## Test streaming parser ## Test streaming parser