Matt Gardner <four712@xxxxxxxxx> writes: > Even though the grep that ships with macOS is GNU compatible? > > $ which grep > /usr/bin/grep > $ grep -V > grep (BSD grep) 2.5.1-FreeBSD > $ grep -E \\btest\\b test.pl > sub test { return; } It seems that use of REG_ENHANCED bit (which gives some GNUism enhancement to regex engine of BSD origin) is inconsistent even among tools shipped by Apple, cf. https://lore.kernel.org/git/4e03ea47-b0aa-d69e-6c54-fcbadb3b0641@xxxxxx/ which may even contribute to the confusion. I think we recently (of course this is after we stopped doing NO_REGEX and switched to macOS native regex library) started using the ENHANCED bit only for BRE and we do not use ENHANCED bit for ERE, and the cited thread (which has "pcre" on the subject, but it turns out that the symptom had nothing to do with pcre) discussed possible use of the same enhanced bit for ERE by us.