Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(scripts): retired-phrases guard parses on macOS /bin/bash 3.2 (#5810)

garrytan6219814565d6
diff --git a/scripts/check-retired-phrases.sh b/scripts/check-retired-phrases.sh
index 7850c092bf..ff0211037c 100644
--- a/scripts/check-retired-phrases.sh
+++ b/scripts/check-retired-phrases.sh
@@ -40,7 +40,10 @@ fi
EXEMPT='^(docs/(designs|test-audit|incidents|plans|proposals|research|issues|superpowers|migrations)/|skills/migrations/|docs/architecture/wave-1-)'
# pattern<TAB>current instruction
-RETIRED=$(cat <<'EOF'
+# Read with `read -d ''`, never a `cat` heredoc inside a command substitution:
+# macOS /bin/bash 3.2 quote-scans that heredoc and dies on the apostrophe and
+# the odd backticks in these rows, so the guard could not even parse there.
+IFS= read -r -d '' RETIRED <<'EOF' || true
MIGRATIONS`? array Migrations are one file each: `bun run new:migration <snake_name>` scaffolds src/core/schema-migrations/v<NNN>-<name>.ts and regenerates registry.generated.ts; migrate.ts is only the runner.
append(s|ing)? (an entry |a migration |it )?to (the )?`?MIGRATIONS Migrations are one file each: `bun run new:migration <snake_name>` (src/core/schema-migrations/), never an array append.
lands in BOTH A migrated storage domain's SQL lives once in src/core/engine-sql/<domain>.ts and both engines delegate to it; only unmigrated or dialect-specific methods are written per engine (scripts/engine-sql-baseline.tsv).
@@ -48,7 +51,6 @@ Add the case to A CLI-only command is a record in src/cli/command-table.ts plus
region-exempt The module-size ratchet has one policy (`ratchet`); migrate.ts is runner-only and ratcheted like every other file.
schema\.sql \+ pglite-schema\.ts|pglite-schema\.ts \+ schema\.sql Schema DDL has one hand-edited copy: edit src/schema.sql (or the TS fragment its region banner names), then `bun run build:schema` regenerates schema-embedded.generated.ts and pglite-schema.generated.ts.
EOF
-)
fail=0
hits=0
diff --git a/test/scripts/check-retired-phrases.test.ts b/test/scripts/check-retired-phrases.test.ts
index 83fbd48605..4b6f07fa00 100644
--- a/test/scripts/check-retired-phrases.test.ts
+++ b/test/scripts/check-retired-phrases.test.ts
@@ -9,12 +9,12 @@
* them.
* Fails when: a retired phrase in a scanned location stops failing, an exempt
* location starts failing, or the failure loses its FAIL / Why / Fix / See
- * lines or the file:line.
+ * lines or the file:line, or the script stops parsing under macOS /bin/bash 3.2.
* Seam: GBRAIN_GUARD_ROOT pointed at temp trees.
*/
import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
import { spawnSync } from 'node:child_process';
-import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
@@ -91,3 +91,27 @@ describe('check-retired-phrases.sh', () => {
expect(r.status).toBe(0);
});
});
+
+// macOS ships /bin/bash 3.2, which quote-scans a heredoc inside $(...) and so
+// could not parse the retired table's prose (an apostrophe, odd backticks):
+// `bun run verify` failed this guard and guard-self-test on every Mac. Run the
+// guard under /bin/bash itself so a Mac catches it, and pin the table read
+// textually so Linux CI (bash 5 parses either form) catches it too.
+describe('check-retired-phrases.sh under /bin/bash (3.2 on macOS)', () => {
+ it('parses', () => {
+ const r = spawnSync('/bin/bash', ['-n', SCRIPT], { encoding: 'utf8' });
+ expect(r.stderr).toBe('');
+ expect(r.status).toBe(0);
+ });
+
+ it('still flags a retired phrase', () => {
+ write('docs/guides/x.md', '# Guide\n\nSee the MIGRATIONS array.\n');
+ const r = spawnSync('/bin/bash', [SCRIPT], { encoding: 'utf8', env: { ...process.env, GBRAIN_GUARD_ROOT: root } });
+ expect(r.status).toBe(1);
+ expect(r.stderr).toContain('FAIL: docs/guides/x.md:3 retired phrase "MIGRATIONS array"');
+ });
+
+ it('reads the retired table without a heredoc inside $(...)', () => {
+ expect(readFileSync(SCRIPT, 'utf8')).not.toMatch(/\$\(\s*cat\s+<</);
+ });
+});