fix(test): §79 macOS/BSD portability — awk $-anchor + wc leading whitespace - #69
Merged
Conversation
…tespace
Three §79 (`sandy --gc`) checks passed in CI (Ubuntu/GNU) but failed on a
macOS host. Both root causes are BSD-userland vs GNU differences in the TEST
harness only — the sandy --gc product code is unaffected (every per-container
identity assertion passed on macOS; only these three broke):
1/2. The two structural checks extracting the --gc dispatcher block used
`awk "/^if \[\[ \"\${1:-}\" == \"--gc\" \]\]; then/,/^fi$/"`. macOS's BWK awk
("the one true awk") treats `\$` as the `$` end-of-line ANCHOR (dropping the
backslash) rather than a literal `$`, putting an anchor mid-pattern so the
range start never matches → empty region → the greps for
`_sandy_gc_dry_run` / `_sandy_dead_owner_containers_list reap` fail. GNU awk
and mawk treat `\$` as a literal `$`, so CI passed. Rewrote the start pattern
to `/^if .*--gc/` (no literal `$`), which matches exactly the one dispatcher
line and extracts the identical 143-line region on gawk/mawk/BWK awk.
3. `sort -u "$1" | wc -l | grep -qx 5` — BSD `wc -l` emits leading whitespace
(` 5`) even when piped, so the whole-line match `grep -qx 5` fails on
macOS. Replaced with `[ "$(... | wc -l | tr -d ' ')" = 5 ]`.
Verified: both structural checks pass under mawk (BSD regex proxy); the count
fix handles leading-whitespace wc. No other `\${1:-}`-in-awk or
`wc -l | grep -qx` traps remain in the suite.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Three §79 (
sandy --gc) checks pass in CI (Ubuntu/GNU) but fail on a macOS host. Both root causes are BSD-vs-GNU userland differences in the test harness only — thesandy --gcproduct code is unaffected (every per-container identity assertion passed on macOS; only these three broke):\$as the$anchor (drops the backslash) → the region-start regex has an anchor mid-pattern → never matches → empty region → grep fails/^if .*--gc/(no literal$)wc -lemits leading whitespace ( 5) even when piped →grep -qx 5whole-line match fails[ "$(… | wc -l | tr -d ' ')" = 5 ]Verification
/^if .*--gc/matches exactly the one dispatcher line.wc.\${1:-}-in-awk orwc -l \| grep -qxtraps remain.bash -nclean.Test-only; no product-code change. This is the same class as the earlier
_BASE_BUILD_Q/sleep infinitymacOS breaks — CI (GNU) can't catch them; surfaced by a maintainer host run.🤖 Generated with Claude Code