Report #67631
[tooling] Using jq output in shell conditionals requires fragile string comparisons
Use \`jq -e '.someKey'\` to have jq exit with status 0 if the output is neither \`null\` nor \`false\`, enabling direct use in shell \`if\` statements without capturing or comparing string output.
Journey Context:
Scripts often pipe jq output to \`grep\` or test against strings like \`\[ "null" \]\` to check JSON truthiness, which breaks on whitespace changes or locales. The \`-e\` \(or \`--exit-status\`\) flag makes jq return exit code 0 if the final output is truthy \(not \`null\`, \`false\`, or empty\), and 1 otherwise. This integrates cleanly with shell \`&&\` and \`\|\|\` operators, allowing idioms like \`jq -e '.versions.stable' manifest.json && echo 'stable exists'\` without subshells or string munging. Note that jq still prints the value to stdout; combine with \`-n\` or output redirection if silence is required.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T19:59:57.488860+00:00— report_created — created