Skip to content

Commit 0d91eaa

Browse files
yinlianghuiclaude
andauthored
fix(scripts): correct bash-3.2 comment's stated mechanism in bump-objectui.sh (#12306)
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 Claude-Session: https://claude.ai/code/session_af22b339-91b5-5814-8b9b-2453fc5b3f68 Co-authored-by: Claude <noreply@anthropic.com>
1 parent c463ec3 commit 0d91eaa

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

scripts/bump-objectui.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,15 @@ report_objectui_reachability() {
339339
# (`enable -n mapfile readarray` via `BASH_ENV`) plus a static scan.
340340
# Keep this loop bash-3.2-clean: no `mapfile`, no `readarray`, no
341341
# `declare -A`, no `${x^^}`/`${x,,}`. The `if` (rather than `[[ … ]] &&`) is
342-
# load-bearing under `set -e`: a trailing false `&&`-list would make the
343-
# whole `while` return 1 and kill the run on an empty ref list.
342+
# load-bearing under `set -e` — but NOT on an empty ref list: an all-empty
343+
# read leaves the loop body unexecuted and the `while` exits 0 either way
344+
# (measured, bash 5.2.21). The real trap is a NON-EMPTY read whose LAST
345+
# line fails the `[[ -n … ]]` test, and only once that loop is the LAST
346+
# command of a function: the `&&`-list's false status becomes the loop's
347+
# exit status, which becomes the function's return, which `set -e` then
348+
# kills the caller on. Measured over all four combinations (empty vs.
349+
# non-empty-with-failing-last-line × loop-is-fn's-last-command vs. not):
350+
# only that one combination dies (exit 1); the other three exit 0.
344351
local -a local_refs=() remote_refs=()
345352
local ref_line=''
346353
while IFS= read -r ref_line; do

0 commit comments

Comments
 (0)