Make jq_lacks set -e-safe - #213
Merged
Merged
Conversation
The prior form ran `jq -e` as a bare command then `rc=$?`; outside a conditional, set -e would abort on the exit-1 no-match before rc is captured. Capture the status with `|| rc=$?` (a list, exempt from errexit) so a no-match returns "lacks" and a real jq error (>1) still propagates, in any calling context. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens repo-config/configure.sh’s jq_lacks helper so it behaves correctly under set -euo pipefail, reliably distinguishing jq “no match” (exit 1) from real jq errors (>1) without risking an unintended errexit abort.
Changes:
- Capture
jq -eexit status using|| rc=$?so exit-1 “no match” does not triggerset -etermination. - Keep propagating jq errors (>1) while treating exit 1 as a successful “lacks” result.
- Add an explanatory comment describing why the
||list form is used.
This was referenced Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Capture jq's exit code with
|| rc=$?(a list is exempt from errexit) so an exit-1 no-match returns 'lacks' rather than risking aset -eabort outside a conditional, while still propagating a real jq error (>1). Verified underset -euo pipefailfor match / no-match / jq-error. Follow-up to PR #211.