Repository navigation
task-remove hangs at 100% CPU in _la_strip_line under bash 3.2 with a UTF-8 locale (#266) - #269
Merged
Merged
Conversation
… UTF-8 locale: test for content with grep, not a whitespace substitution (#266) `_la_strip_line` and `_la_workflow_doc_tail` decided "is anything left?" with `${s//[[:space:]]/}`. Bash 3.2's matcher is superlinear on a bracket class under a multibyte locale: on macOS /bin/bash an 8KB UTF-8 file took 25s and a ~30KB CLAUDE.md never finished. Both now call `_la_has_content`, a `grep -q '[^[:space:]]'` on a here-string. It is not a pipe: under the callers' pipefail an early-exiting `grep -q` would SIGPIPE the writer and a non-blank CLAUDE.md would read as blank, then get deleted. `_la_workflow_doc_tail` returns the tail verbatim; its one caller only tests it for emptiness. Tests drive both functions on a ~40KB UTF-8 file under a UTF-8 locale with a 20s alarm (the old code hits it: status 142), and pin the whitespace-only cases. Forcing the helper to either answer turns tests red. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… UTF-8 locale: build the test fixture without reopening /dev/stdout (#266) The doc-tail test wrote its big UTF-8 body with `> /dev/stdout` inside a block already redirected to the doc. On Linux that reopens the file O_TRUNC, wiping the marker lines the block had just written, so the doc read as pre-markers and the test failed on ubuntu only. The helper now writes to stdout and the callers redirect. Against the old lib both large-file tests still hit the alarm (status 142). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
Spec complianceDelivers #266. Both Code-review findingsNo correctness issues found.
Verification, run on macOS
Verdictclean. Nothing to fix in this PR. PM holds the merge decision. |
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.
Closes #266
What
Two "is anything left?" checks in
lib/loadout-artifacts.shused${s//[[:space:]]/}. Bash 3.2's matcher is superlinear on a bracket class under a multibyte locale. On macOS/bin/bash, an 8KB UTF-8 file took 25s and a ~30KBCLAUDE.mdnever finished. The two checks:_la_strip_line: didCLAUDE.md/.gitignorehold only task-init's line?_la_workflow_doc_tail: does the workflow doc need a<doc>.bak? The issue didn't name this one; the suggested grep for other${var//[[:class:]]/}uses turned it up. There are no others in the repo.Both now go through a new
_la_has_content, which runsgrep -q '[^[:space:]]'on a here-string. A pipe (the issue's suggestion) is unsafe here:task-remove/task-configrun underpipefail, and agrep -qthat exits on its first match can SIGPIPE theprintf. The non-blank file would then read as blank, and the user'sCLAUDE.mdwould be deleted._la_workflow_doc_tailnow returns the tail verbatim instead of whitespace-stripped; its only caller tests-n.Tests
perl alarm. They redirect output rather than pipe it, so a hang kills the spinning process instead of orphaning it. On the old code both hit the alarm (status 142).CLAUDE.md, and a doc tail of stub plus whitespace counts as empty._la_has_contenttoreturn 1or toreturn 0turns tests red (old and new)../run_tests.sh: 1370 ok, 0 failing.tools/check-drift.shclean.shellcheck -x lib/loadout-artifacts.shclean.The CHANGELOG has an entry under Fixed. No
task-initre-run needed.🤖 Generated with Claude Code