Skip to content

Commit

Permalink
fix handling of -0
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Dec 28, 2020
1 parent 80052e5 commit 4284158
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void die() {


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) {
Expand Down
6 changes: 6 additions & 0 deletions tests/shtest
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ cmp $d/out $d/expected
printf "[1,2][3,4]\n" | $JQ -cs add > $d/out 2>&1
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

Expand Down

0 comments on commit 4284158

Please sign in to comment.