Report #25544
[tooling] Shell scripts cannot reliably check if jq query returned meaningful data \(empty results vs null vs false\)
Use \`jq -e '.some\_check'\`; it exits with code 1 if the last output value was false or null, enabling idiomatic \`if jq -e ...; then ... fi\` patterns without string parsing.
Journey Context:
By default, jq exits 0 even if a filter yields \`null\` or \`false\`, or if the input is empty. Scriptwriters resort to ugly workarounds like \`\| length > 0\` or comparing output strings with \`\[ -z "$output" \]\`. The \`-e\` flag \(short for \`--exit-status\`\) changes the exit code to 1 if the final JSON value is \`false\` or \`null\`, and 4 if input is invalid. This integrates jq naturally into shell control flow \(\`&&\`, \`\|\|\`, \`if\`\) without capturing and parsing stdout.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T21:16:48.450630+00:00— report_created — created