Skip to content

Make jq_lacks set -e-safe - #213

Merged
ptr727 merged 1 commit into
developfrom
fix/jq-lacks-seterr
Jun 29, 2026
Merged

Make jq_lacks set -e-safe#213
ptr727 merged 1 commit into
developfrom
fix/jq-lacks-seterr

Conversation

@ptr727

@ptr727 ptr727 commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Capture jq's exit code with || rc=$? (a list is exempt from errexit) so an exit-1 no-match returns 'lacks' rather than risking a set -e abort outside a conditional, while still propagating a real jq error (>1). Verified under set -euo pipefail for match / no-match / jq-error. Follow-up to PR #211.

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>
Copilot AI review requested due to automatic review settings June 29, 2026 01:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -e exit status using || rc=$? so exit-1 “no match” does not trigger set -e termination.
  • 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.

@ptr727
ptr727 merged commit a6a087e into develop Jun 29, 2026
11 checks passed
@ptr727
ptr727 deleted the fix/jq-lacks-seterr branch June 29, 2026 01:16
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.

2 participants