On Sat, May 21, 2022 at 3:05 AM Paul Eggert <egg...@cs.ucla.edu> wrote: > Looking again at grep bug 39678 <https://bugs.gnu.org/39678> I noticed > that the bug occurs even when grep is not coloring: > > echo a | grep -oi --color=never '\a' > > This outputs nothing and exits with status 0, which is clearly wrong.
Wrong, indeed! > I tracked this down to a bug buried deep in the bowels of glibc regex, a > bug that Tomasz also spotted. It's not trivial to fix (the fix that > Tomasz sent in doesn't feel right, at least for \X where X is a > multibyte letter) and any fix would be low priority since the bug occurs > only in regular expressions like '\a' that have unspecified behavior - > which means the behavior though wrong nevertheless conforms to POSIX. > > I'm inclined to address this by having GNU 'grep' diagnose unspecified > regexps like '\a' and exit with status 2, much as it already diagnoses > unspecified regexps like '[:alpha:]'. If this approach sounds too > drastic, a gentler approach would be for 'grep' to warn about '\a' > without changing the exit status for now, and escalate the warning to > exit with status 2 in a later 'grep' release. In my experience, there are many lurking uses of things like '\a', and would like to ease into this gently, so I much prefer your latter approach: warn now, and change grep's exit status later -- at least 6 months to a year later, to give people at least a chance to fix their offending uses before they break. Thanks for all the improvements!