Skip to content

fix(wire-company-brain): re-wire works on macOS awk; a failed rewrite no longer says Updated - #599

Merged
MendixMau merged 1 commit into
masterfrom
triage/598-brain-bsd-awk
Oct 31, 2026
Merged

MendixMau merged 1 commit into
masterfrom
triage/598-brain-bsd-awk

Conversation

@MendixMau

Copy link
Copy Markdown
Owner

Fixes #598

Direct lane

What changed and why:

bin/wire-company-brain.sh passed the multi-line pointer block to awk as -v blk="$block". BSD awk on macOS (20200816) refuses a newline in a -v value. As a result, every re-run (a moved brain, a changed block) left all surfaces untouched, yet still printed Updated: … rewritten in place and counted the surface.

What this PR changes:

  • The block now reaches awk through the environment (ENVIRON["BLK"]), which is POSIX.
  • The rewrite and append paths now print Updated only when awk && mv succeeded.
  • On failure the script prints FAILED: …, leaves the file unchanged, and does not count the surface.

Impact

Row Answer
Process None. No gate reads this script and nothing new blocks. A failed surface now prints FAILED instead of a false Updated. The exit code is unchanged.
Dependencies Only bin/wire-company-brain.sh and its fixture. No shared files, no new tools. ENVIRON works in BSD awk, gawk and mawk.
Context cost None: no routed or always-loaded file touched.
Behaviour n/a: script only.
Runtime n/a.

Field evidence: reported in #598 from a scratch copy of a field-run project (three surfaces) on macOS 26 / BSD awk 20200816. The issue reproduces it on a clean master with an empty fixture. The issue's suggested ENVIRON change was tested there on BSD awk. This PR has not been run on macOS from here: the build container only has mawk.

Proof: the new section tests/wave2/test-company-brain.sh T2c uses a stub awk that enforces BSD's no-newline-in--v rule and otherwise runs the real awk. It also uses a stub that always fails, to check the reporting.

fixed (53c0560):                     PASS 50  FAIL 0
same fixture, 2ba8158's script:      PASS 46  FAIL 4
  FAIL re-point under BSD-awk rules left the old path: awk: newline in string
       Updated: CLAUDE.local.md — company brain block rewritten in place.
  FAIL failed rewrite still printed Updated
  FAIL no FAILED line
  FAIL count wrong: ... written to 1 instruction surface(s).

Master output under the stub matches the issue's report line for line. Only this fixture covers the script (grep -rl wire-company-brain tests/). bin/check-portability.sh is clean (335 files). The full suites were not run, per CLAUDE.md.

Review: pending independent review


Generated by Claude Code

… no longer says Updated

The block was passed to awk as -v blk="$block". BSD awk (macOS, 20200816) refuses a newline
in a -v value, so every re-run left the files untouched while still printing "Updated: ...
rewritten in place" and counting the surface. The block now goes through the environment
(ENVIRON["BLK"]), and a failed rewrite or append prints FAILED, leaves the file unchanged and
is not counted.

Proof: tests/wave2/test-company-brain.sh T2c, a stub awk enforcing BSD's -v rule.
Fixed: PASS 50 FAIL 0. Same fixture with 2ba8158's script: PASS 46 FAIL 4, reproducing the
reported "awk: newline in string" followed by "Updated: ...".
Field: reported in #598 on macOS 26 / BSD awk (three surfaces of a field-run project copy).

Fixes #598

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018LeNWZV2sVH62vkgfYh5u5
@MendixMau
MendixMau merged commit 428b6af into master Oct 31, 2026
2 checks passed
MendixMau pushed a commit that referenced this pull request Oct 31, 2026
MendixMau pushed a commit that referenced this pull request Oct 31, 2026
MendixMau pushed a commit that referenced this pull request Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] wire-company-brain.sh: re-run fails on macOS awk and still reports Updated

2 participants