Make the README mksync check runnable on macOS - #390
Open
twannooitmeer wants to merge 1 commit into
Open
Conversation
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>
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.
Summary
The README check normalises both sides before diffing:
-zis a GNU extension. BSD sed, which is what macOS ships, rejects it:Because the flag fails on both sides,
diffends 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
$(...)already strips every trailing newline, andprintf '%s\n'puts exactly one back, so the normalisation is identical with no GNU-only flag. Thediff -uoutput on failure is unchanged.Verified on macOS
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.