#5772·gbrain

brain-pdf: GNU-only sed frontmatter strip yields an empty PDF on macOS (exit 0)

Author: chrisquorumCreated Sep 30, 2026Updated Sep 30, 2026

Summary

skills/brain-pdf/SKILL.md strips YAML frontmatter with a GNU-only sed expression. On macOS (BSD sed) the command errors, the cleaned file is empty, and make-pdf still exits 0 with an empty PDF, so the skill reports success on a blank render.

Where

skills/brain-pdf/SKILL.md:89 at v0.60.11.0 (f8d1e3936):

bash
sed '1{/^---$/!q}; /^---$/,/^---$/d' "$RAW" > "$CLEAN"

Reproduce (macOS, gbrain 0.60.11.0, gstack make-pdf installed)

Following the skill's Invocation block on any page with frontmatter:

$ sed '1{/^---$/!q}; /^---$/,/^---$/d' page.md > clean.md
sed: 1: "1{/^---$/!q}; /^---$/,/ ...": extra characters at the end of q command
$ wc -c clean.md
0 clean.md
$ CONTAINER=1 "$P" generate clean.md out.pdf; echo $?
Done in 4.0s. 0 words · 1KB · out.pdf
0

Input page: 1107 bytes. Output: a 740-byte PDF with 0 words.

Why

BSD sed requires ; or a newline before } after a command inside a {...} block, so !q} is parsed as q followed by extra characters. GNU sed accepts it. The skill is mutating: false and has no guard, so the agent receives exit 0 and a PDF path.

Expected

The frontmatter strip works on macOS and Linux. Alternatively, the skill checks that $CLEAN is non-empty (or that make-pdf's word count is > 0) before reporting success.

Related

#4182 fixed a similar GNU-only grep -P portability issue in smoke-test.