test(coverage-audit): a fenced plain-word caption in a successful && read chain is display only

Census 36776104571 plan-eng capture read both owned files with cat -n in one
successful && chain; the caption 'echo "=== git diff main --stat ==="' fell
outside the two-token caption grammar, so both reads lost credit. Accept a fenced
caption of plain words; unfenced command strings, expansions, redirection,
-e escapes and ; / || tails stay rejected.
This commit is contained in:
garrytan committed 2026-09-30 22:07:25 +00:00
1 parent 190e650d97
commit 1751985a21
2 files changed
+20 -1

No files matched your search

+3 -1
View File
@@ -174,7 +174,9 @@ function readsFile(command: unknown, file: string, cwd: string, output: unknown,
const andDisplay = (p: string) => {
if (p === 'echo' || /^echo\s+[-=]+$/.test(p) || /^echo [-=]{2,} [A-Za-z0-9_.\/-]+ [-=]{2,}$/.test(p)) return true;
const caption = /^echo\s+(.+)$/.exec(p), value = caption && literal(caption[1]!);
if (value && /^[-=]{2,}(?:\s*[A-Za-z0-9_][A-Za-z0-9_./-]*(?:\s+(?:vs|and)\s+[A-Za-z0-9_][A-Za-z0-9_./-]*)?\s*)?[-=]{2,}$/.test(value)) return true;
// A fenced caption may name the next display in plain words, such as
// "=== git diff main --stat ==="; an unfenced command string stays data.
if (value && /^[-=]{2,}(?:\s*[A-Za-z0-9_][A-Za-z0-9_./-]*(?:\s+[A-Za-z0-9_./-]+)*\s*)?[-=]{2,}$/.test(value)) return true;
return /^git\s+diff(?:\s+[A-Za-z0-9_][A-Za-z0-9_./~^-]*)?\s+--stat$/.test(p) ||
/^git\s+log\s+--oneline\s+[A-Za-z0-9_][A-Za-z0-9_./~^-]*$/.test(p);
};