Repository navigation
[Sprint] sprint-loop-29 - #25
Merged
Merged
Conversation
scealiontach
marked this pull request as ready for review
April 30, 2026 23:40
test(SUR-1936): check-no-bare-ret fixtures; exclude fixture dir in pre-commit
test(SUR-1936): add bats spec for check-no-bare-ret hook
fix(tests): treat '#' as comment only at start-of-token in check-no-bare-ret
The hook's `apply_line_braces` parser unconditionally treated '#' as a
comment-start, which is wrong inside parameter expansions like
${var#prefix}, ${var##prefix}, and ${#var}. When such an expansion
appeared in a function body before its closing '}', the parser broke at
'#' and never decremented for the matching '}', leaving fn_body_depth
one higher than it should be. A subsequent function-close '}' then left
the hook still considering itself in-function, and any later top-level
bare capture (`ret=$?` etc.) was wrongly flagged.
In bash, '#' starts a comment only at start-of-token (start of line or
after whitespace). Restrict the comment-break to that condition so
parameter expansions parse cleanly. Add a fixture using *unquoted*
${var#…} / ${var##…} / ${#var} forms (the bug only fires in the bare
`norm` state — inside double-quotes the parser already skipped '#'),
followed by a top-level capture, plus a bats case asserting the live
hook accepts the fixture.
scealiontach
force-pushed
the
sprint/2026-04-30-sprint-loop-29
branch
from
April 30, 2026 23:59
89e5d8b to
07f115d
Compare
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.
Sprint plan — 2026-04-30 — sprint-loop-29
Sprint goal
Strengthen the SUR-1874
check-no-bare-retpre-commit hook so its brace-tracking matches real bash structure: nested{ ... }groups must not reset “inside function” state, eliminating the false-negative path where a bareret=$?-style capture after a closing}in a brace group is missed. Align implementation with the hook’s stated enforcement boundary (and the issue’s preferred “option 1” scope) without expanding to a full AST or shellcheck-plugin solution this sprint.Selected issues
SUR-1936 — Anti-pattern: check-no-bare-ret hook resets state on bare
}lines, missing captures inside nested brace groups}lines, missing captures inside nested brace groups}as leaving a function, but bash allows{ ... }groups inside functions, soin_functionandlocalsare cleared too early and bare captures of$?after the inner}are not flagged. A secondary fragility is regex-based function detection (name()vs real function defs). File:tests/check-no-bare-ret.sh(lines called out ~38–72). Suggested fixes ordered by effort: (1) track brace depth and only reset when depth returns to zero, (2)shfmt/JSON AST, (3) shellcheck-level rule. Option 1 is explicitly the smallest targeted fix.}does not clear function context while the outer function body continues.locals/in_functionsemantics remain correct for existing patterns (function entry/exit,locallines, capture detection).tests/check-no-bare-ret.share consistent with actual behavior (no overstated guarantees).{ ... }fixture where a bare capture after the inner}must be reported, and a control case withlocalstill passes.pre-commithookcheck-no-bare-retstill runs successfully on the repo’s bash libraries.ret,exit_code,exit_status,rc).FUNC_DEF_PATif time permits.Risks + mitigations
}inside strings, comments, or here-docsbash/style; extend tests with quoted edge cases if discovered.}-only lines at true function end}still exits the function as today.FUNC_DEF_PATstill brittle for rarename()shapesshell-scriptsBacklog issue existed at planning timeOut of scope
shfmt -tojson+jqor a shellcheck plugin (options 2–3 in the issue).shell-scriptsor team Surinis.Linear Evidence
ce9ebfde-ff2b-4f54-90f1-c388591ca110, key SUR)a43901a0-b02b-4009-aae1-a6e8903d127d)list_issueswithteam=Surinis,project=shell-scripts,state=Backlog,includeArchived=false,limit=250; per-issueget_issuewithincludeRelations=true;list_issueswithparentId=SUR-1936for sub-issue check;list_commentson selected issue.[][](open PR file list was empty)Sub-issue status
No selected issues have sub-issues in Linear. SUR-1936 has zero child issues; no parent was deferred for incomplete sub-work.
Linear state transitions