From a4dc82450d88f420f593488aa6762b9fe8d2bafa Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 25 Aug 2026 17:16:47 +0000 Subject: [PATCH] fix(scripts): correct bash-3.2 comment's stated mechanism in bump-objectui.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bash-3.2 note explaining why the ref-collection loop uses `if [[ -n "$x" ]]; then …; fi` rather than a trailing `[[ … ]] && …` attributed the trap to the empty-list case. Measured on bash 5.2.21, that does not reproduce: an all-empty read leaves the loop body unexecuted and the `while` exits 0. The real trap is a non-empty read whose last line fails the test, and only once that loop is the last command of a function — the `&&`-list's false status becomes the loop's exit status, becomes the function's return, and `set -e` kills the caller on that. Measured over all four combinations (empty vs. non-empty-with-failing-last- line × loop-is-fn's-last-command vs. not): only that one combination exits 1; the other three exit 0. The `if` form itself is unchanged and correct — only the stated reason was wrong. Fixes #12222 Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_af22b339-91b5-5814-8b9b-2453fc5b3f68 --- scripts/bump-objectui.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/bump-objectui.sh b/scripts/bump-objectui.sh index c1ff2049c4..e93ba39910 100755 --- a/scripts/bump-objectui.sh +++ b/scripts/bump-objectui.sh @@ -339,8 +339,15 @@ report_objectui_reachability() { # (`enable -n mapfile readarray` via `BASH_ENV`) plus a static scan. # Keep this loop bash-3.2-clean: no `mapfile`, no `readarray`, no # `declare -A`, no `${x^^}`/`${x,,}`. The `if` (rather than `[[ … ]] &&`) is - # load-bearing under `set -e`: a trailing false `&&`-list would make the - # whole `while` return 1 and kill the run on an empty ref list. + # load-bearing under `set -e` — but NOT on an empty ref list: an all-empty + # read leaves the loop body unexecuted and the `while` exits 0 either way + # (measured, bash 5.2.21). The real trap is a NON-EMPTY read whose LAST + # line fails the `[[ -n … ]]` test, and only once that loop is the LAST + # command of a function: the `&&`-list's false status becomes the loop's + # exit status, which becomes the function's return, which `set -e` then + # kills the caller on. Measured over all four combinations (empty vs. + # non-empty-with-failing-last-line × loop-is-fn's-last-command vs. not): + # only that one combination dies (exit 1); the other three exit 0. local -a local_refs=() remote_refs=() local ref_line='' while IFS= read -r ref_line; do