git/list[1] front-page[2] threads[3] people[4] search[5] about
 

-P '\d' in GNU and git grep

From
Paul Eggert <eggert@cs.ucla.edu>
Date
Apr 3, 2023, 21:38 UTC
Message-ID
<2554712d-e386-3bab-bc6c-1f0e85d999db@cs.ucla.edu>

I've recently done some bug-report maintenance about a set of GNU grep bug reports related to whether whether "grep -P '\d'" should match non-ASCII digits, and have some thoughts about coordinating GNU grep with git grep in this department.

GNU Bug#62605[1] "`[\d]` does not work with PCRE" has been fixed on Savannah's copy of GNU grep, and some sort of fix should appear in the next grep release. However, I'm leaving the GNU grep bug report open for now because it's related to Bug#60690[2] "[PATCH v2] grep: correctly identify utf-8 characters with \{b,w} in -P" and to Bug#62552[3] "Bug found in latest stable release v3.10 of grep". I merged these related bug reports, and the oldest one, Bug#60690, is now the representative displayed in the GNU grep bug list[4].

For this set of grep bug reports there's still a pending issue discussed in my recent email[5], which proposes a patch so I've tagged Bug#60690 with "patch". The proposal is that GNU grep -P '\d' should revert to the grep 3.9 behavior, i.e., that in a UTF-8 locale, \d should also match non-ASCII decimal digits.

In researching this a bit further, I found that on March 23 Git disabled the use of PCRE2_UCP in PCRE2 10.34 or earlier[6], due to a PCRE2 bug that can cause a crash when PCRE2_UCP is used[7]. A bug fix[8] should appear in the next PCRE2 release.

When PCRE2 10.35 comes out, it appears that 'git grep -P' will behave like 'grep -P' only if GNU grep adopts something like the solution proposed in [5].

[1]: https://bugs.gnu.org/62605 [2]: https://bugs.gnu.org/60690 [3]: https://bugs.gnu.org/62552 [4]: https://debbugs.gnu.org/cgi/pkgreport.cgi?package=grep [5]: https://lists.gnu.org/archive/html/grep-devel/2023-04/msg00004.html [6]: https://github.com/git/git/commit/14b9a044798ebb3858a1f1a1377309a3d6054ac8 [7]: https://lore.kernel.org/git/7E83DAA1-F9A9-4151-8D07-D80EA6D59EEA@clumio.com/ [8]: https://github.com/git/git/commit/14b9a044798ebb3858a1f1a1377309a3d6054ac8

Next: Jim Meyering
Message 1 of 19 in “-P '\d' in GNU and git grep”
  1. Paul EggertApr 3, 2023
  2. Jim MeyeringApr 4, 2023
  3. Paul EggertApr 4, 2023
  4. Jim MeyeringApr 4, 2023
  5. Carlo ArenasApr 4, 2023
  6. Paul EggertApr 4, 2023
  7. Junio C HamanoApr 4, 2023
  8. Paul EggertApr 5, 2023
  9. Paul EggertApr 5, 2023
  10. Junio C HamanoApr 5, 2023
  11. Jim MeyeringApr 5, 2023
  12. Paul EggertApr 5, 2023
  13. Carlo ArenasApr 5, 2023
  14. demerphqApr 6, 2023
  15. Paul EggertApr 7, 2023
  16. demerphqApr 6, 2023
  17. Paul EggertApr 7, 2023
  18. Carlo ArenasApr 8, 2023
  19. Paul EggertApr 8, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.