On second read of the grep man page on Mac, what exactly says is, "The grep command first appeared in Version 6 AT&T UNIX." which doesn't really mean anything.
All I know for certain is that Unix and it's progeny as well as the flattering imitations (*ix) represent a 50+ year bacchanal of drunken development glory. I'm pretty sure Mac OS is not descended from system 5, but is supposed to be POSIX-compliant (read: the fun stuff is missing). That's what I love about standards; write once, debug everywhere. ________________________________ From: David G. Pickett <[email protected]> Sent: Tuesday, October 7, 2025 7:00 PM To: Paul Eggert <[email protected]>; Bob Peraino <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: bug#79550: Grammar bug in grep External Message: Use Caution Wow, so many UNIX ancestral trails, so is MAC OS really a derivative of AT&T System 5 V 4? On Monday, October 6, 2025 at 11:32:37 AM EDT, Bob Peraino <[email protected]> wrote: That's not the original example I gave. Anyway, according to the Mac man page, it is AT&T origin. ________________________________ From: David G. Pickett <[email protected]> Sent: Friday, October 3, 2025 2:57 PM To: Bob Peraino <[email protected]>; Paul Eggert <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: bug#79550: Grammar bug in grep External Message: Use Caution What's the problem? On wsl2 Ubuntu egrep, presumably from open source, says: dgp:~ $ egrep '^1[2,3]2$' <<! 122 132 12 13 23 22 33 ! 122 132 dgp:~ $ On Wednesday, October 1, 2025 at 03:49:59 PM EDT, Paul Eggert <[email protected]> wrote: The behavior you describe is documented and is not a bug; see: https://www.gnu.org/software/grep/manual/html_node/Problematic-Expressions.html and look for "In an extended regular expression, unescaped ‘{’ that does not begin a valid interval expression." Here are some more details about this portability issue. On 2025-10-01 06:35, Bob Peraino wrote: > ^1{2,3]2$ Because this ERE has an unmatched brace, POSIX says that grep produces undefined results for it; see <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap09.html#tag_09_04_03>, which talks about what happens "If a <left-brace> is not part of a valid interval expression". > The Mac version of grep (AT&T origin) properly flags this: > > % egrep '^1{2,3]2$' > egrep: invalid repetition count(s) Although the macOS behavior conforms to POSIX, I don't think it is AT&T origin. Traditional egrep behaves like GNU grep -E. You can see this, for example, in Solaris 10 egrep, which is closer to the AT&T tradition than macOS egrep is. The traditional behavior also conforms to POSIX since POSIX says grep can do whatever it likes. Traditional egrep and GNU grep -E are more likely to do the intended thing when a user mistakenly thinks that '{' is an ordinary character. macOS egrep diagnoses this use of an unportable ERE that could well be a typo. Neither approach strictly dominates the other.
