Skip to content

fix(builtins): produce empty JSON string for jq -Rs with empty stdin#971

Merged
chaliy merged 1 commit intomainfrom
fix/issue-952-jq-raw-slurp-empty
Apr 2, 2026
Merged

fix(builtins): produce empty JSON string for jq -Rs with empty stdin#971
chaliy merged 1 commit intomainfrom
fix/issue-952-jq-raw-slurp-empty

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 2, 2026

Summary

  • Fix jq -Rs '.' producing no output on empty stdin instead of ""
  • Root cause: early return when input.trim().is_empty() fired before the -Rs code path could create an empty string value
  • Added && !(raw_input && slurp) guard so -Rs with empty stdin proceeds to create Val::from("")

Test plan

  • New spec test: jq_raw_slurp_empty_stdin — verifies printf '' | jq -Rs '.' outputs ""
  • New spec test: jq_raw_slurp_normal — regression test for non-empty input
  • All 121 existing jq spec tests pass
  • Full spec test suite green

Closes #952

When -R (raw input) and -s (slurp) are combined, empty stdin should
produce "" (empty JSON string), not no output. Removed early return
that skipped output when input was empty.

Closes #952
@chaliy chaliy merged commit 9a2caf2 into main Apr 2, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-952-jq-raw-slurp-empty branch April 2, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Builtin jq -Rs on empty stdin produces no output instead of ""

1 participant