Skip to content

Make the README mksync check runnable on macOS - #390

Open
twannooitmeer wants to merge 1 commit into
pytr-org:masterfrom
twannooitmeer:fix/mksync-check-portable
Open

Make the README mksync check runnable on macOS#390
twannooitmeer wants to merge 1 commit into
pytr-org:masterfrom
twannooitmeer:fix/mksync-check-portable

Conversation

@twannooitmeer

Copy link
Copy Markdown
Contributor

Summary

The README check normalises both sides before diffing:

diff -u <(cat README.md | sed -z '$s/\n*$//') <(uvx mksync@0.1.5 README.md | sed -z '$s/\n*$//')

-z is a GNU extension. BSD sed, which is what macOS ships, rejects it:

sed: illegal option -- z

Because the flag fails on both sides, diff ends up comparing two empty streams and the command exits 0. On a Mac it does not merely fail to work: it reports success on a README that is actually stale. A contributor who runs the check locally before pushing gets a green result and then a red CI, which is a confusing way to lose half an hour. That is exactly what happened to me on #382.

Fix

diff -u <(printf '%s\n' "$(cat README.md)") <(printf '%s\n' "$(uvx mksync@0.1.5 README.md)")

$(...) already strips every trailing newline, and printf '%s\n' puts exactly one back, so the normalisation is identical with no GNU-only flag. The diff -u output on failure is unchanged.

Verified on macOS

current README README with a heading added, TOC not regenerated
old command exit 0 exit 0 (wrong)
new command exit 0 exit 1, with the expected one-line TOC diff

I also parsed the workflow YAML, extracted the run: string, and executed it verbatim to confirm both outcomes, rather than testing a hand-retyped approximation of it.

CI on Linux is unaffected, since both forms normalise the same way there.

The check normalised both sides with `sed -z '$s/\n*$//'` before diffing.
`-z` is a GNU extension. BSD sed, which is what macOS ships, rejects it:

    sed: illegal option -- z

Because the flag failed on *both* sides of the diff, the step compared two
empty streams and exited 0. On a Mac it did not merely fail to work, it
reported success on a README that was actually stale, so a contributor
checking locally before pushing got a green result and a red CI.

`$(...)` already strips every trailing newline, and `printf '%s\n'` puts
exactly one back, so the same normalisation happens with no GNU-only flag and
the readable `diff -u` output is kept.

Verified on macOS: the new command exits 0 on the current README, and exits 1
with the expected one-line table-of-contents diff once a heading is added
without regenerating. The old command exits 0 in both cases.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant