Skip to content

critcheck counts a malformed grep pattern as a failure on macOS (BSD grep error wording) #190

Closed as not planned

Description

@AbirAbbas

What happened

On macOS a grep acceptance criterion with a malformed regular expression is counted as a real failure instead of "not counted", because macOS's BSD grep words its errors differently from GNU grep. go/internal/critcheck TestAMalformedCheckWithNoRepairIsNotCounted fails on macOS on main (critcheck_test.go:114: findings = []) and passes on Linux.

Replication

On a Mac: cd go && go test ./internal/critcheck -run TestAMalformedCheckWithNoRepairIsNotCounted -count=1 -v. By hand: echo x | grep -E 'Checksum(' prints grep: parentheses not balanced (exit 2) with BSD grep.

Where

Malformed() (go/internal/critcheck/critcheck.go) matches GNU's regex error wording ("Unmatched …", "Invalid …", "Trailing backslash"). BSD grep says "parentheses not balanced", "brackets ([ ]) not balanced" and lowercase "trailing backslash". Option errors ("unrecognized option") are already caught.

The fix

Recognise the BSD grep regex error messages alongside the GNU ones.

Acceptance

On macOS and Linux, a criterion whose grep pattern is malformed is reported as not counted, and the existing test passes on both.

Activity

  1. AbirAbbas commented on Nov 16, 2026

    @AbirAbbas
    CollaboratorAuthor

    Duplicate of #192, which has the fuller write-up. Filed twice by mistake during the 2026-11-13 macOS check (PR #194 references both).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions