Re: bug#60690: -P '\d' in GNU and git grep
From: Junio C Hamano <hidden>
Date: 2023-04-05 19:38:43
Paul Eggert [off-list ref] writes:
Here are two ways forward to fix this incompatibility (there are other possibilities of course): (A) GNU grep adds a --no-ucp option that acts like 10.43 pcre2grep --no-ucp, and git grep -P follows suit. That is, both GNU and git grep act like 10.43 pcre2grep -u, in that they enable PCRE2_UTF, and also enable PCRE2_UCP unless --no-ucp is given. This would cause \d to match non-ASCII digits unless --no-ucp is given. (B) GNU grep -P and git grep -P mimic pcre2grep in both -u and --no-ucp. That is, they would both do 8-bit-only by default, and use PCRE2_UTF only when -u or --utf is given, and use PCRE2_UCP only when --no-ucp is absent. This would cause \d to match non-ASCII digits only when -u is given but --no-ucp is not. Under either (A) or (B), future pcre2grep -u, GNU grep -P, and git grep -P would be consistent. I mildly prefer (B) but (A) would also work. (One advantage of (B) is that it should be faster....)
For "git grep -P", I would like to hear from Carlo and Ævar; I agree both (A) and (B) would be workable solutions, and have a slight preference on a solution that does not add more options that take only in effect when -P is given, simply because these options are cumbersome to document and explain, but that is a very minor point. Thanks.