From 836f1ac22ab85f1fa1f4c48e9dc2cab1692bf22b Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sun, 28 Jun 2026 18:14:04 -0700 Subject: [PATCH] Make jq_lacks set -e-safe (capture exit via || rc=$?) 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) --- repo-config/configure.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repo-config/configure.sh b/repo-config/configure.sh index b13ea4d..4390cd3 100755 --- a/repo-config/configure.sh +++ b/repo-config/configure.sh @@ -87,7 +87,8 @@ jq_has() { jq -e "$@" >/dev/null 2>&1; } # jq_lacks FILTER... - true iff the jq filter selects nothing (jq exit 1). A real jq error (exit >1, e.g. a # malformed filter or input) is propagated, not treated as "lacks", so the calling assert fails loudly. -jq_lacks() { local rc; jq -e "$@" >/dev/null 2>&1; rc=$?; case "$rc" in 0) return 1 ;; 1) return 0 ;; *) return "$rc" ;; esac; } +# The `|| rc=$?` keeps jq in a list (exempt from set -e) so an exit-1 no-match captures rc instead of aborting. +jq_lacks() { local rc=0; jq -e "$@" >/dev/null 2>&1 || rc=$?; case "$rc" in 1) return 0 ;; 0) return 1 ;; *) return "$rc" ;; esac; } check_ruleset() { # name expected-merge-method expect-linear(true/false) local name="$1" method="$2" linear="$3" id rs