[pcre-dev] [Bug 2294] New: pcregrep -E

Αρχική Σελίδα
Delete this message
Συντάκτης: admin
Ημερομηνία:  
Προς: pcre-dev
Αντικείμενο: [pcre-dev] [Bug 2294] New: pcregrep -E
https://bugs.exim.org/show_bug.cgi?id=2294

            Bug ID: 2294
           Summary: pcregrep -E
           Product: PCRE
           Version: 10.22 (PCRE2)
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: wishlist
          Priority: medium
         Component: Code
          Assignee: ph10@???
          Reporter: enh@???
                CC: pcre-dev@???


in Android up to and including Android P, the grep/egrep/fgrep come from
NetBSD. i'd like to switch us over to PCRE grep, because we ship PCRE on-device
anyway, and i don't see us getting a grep with -P support any other way than
using PCRE.

(ignore the 10.22 --- that's strictly true, but as soon as i've filed this bug
i'll look at getting AOSP updated. i did check the current source and it
doesn't seem to have changed.)

so i tried flipping the switch (in AOSP master right now, grep is PCRE grep),
and got the following bug report (from an existing test that broke):

In Android P and earlier, grep had the options -e and -E.
-e supported basic regular expressions (BRE's)
-E supported extended regular expressions (ERE's, which includes or, and,
etc)

The PCRE grep package only has -e.
In PCRE, -e is the equivalent to Android P's -E. The -e flag has no
equivalent in PCRE.

  This means a few things for compatibility of tests between P & Q:
  Testing code that was written in P may return false positives when running
against Q, or fail entirely:
    For `grep -e "uno|dos"`
        On P: Any line containing "uno|dos" will be returned.
        On Q: All lines containing either "uno" or "dos" will be returned. 
    For `grep -E "uno|dos"`
        On P: All lines containing either "uno" or "dos" will be returned. 
        On Q: STDERR outputs: Usage: pcre2grep [-AaBCcDdeFfHhIilLMNnoqrsuVvwx]
[long options] [pattern] [files]
                                                Type `pcre2grep --help' for
more information and the long options.



from https://www.pcre.org/current/doc/html/pcre2convert.html it looks like i
can implement the BRE/ERE behavior -- and i'm actually volunteering to send you
the patch -- but i wanted to ask whether you'd accept such a change, and
whether you'd want it behind an #if __ANDROID__ or similar?

basically i'd like to make the default BRE and add -E for ERE, to match POSIX
(http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html).

i'm not sure whether you consider the current PCRE grep behavior a bug or a
feature. in the latter case, i'd like to suggest either #if __ANDROID__ or
adding some other PCRE_GREP_POSIX_BEHAVIOR-type macro so i can build this way
for Android without upsetting your existing users (but without maintaining
patches downstream, because one day i'll retire or go under a bus).

(apologies if this should have been on the mailing list instead.)

--
You are receiving this mail because:
You are on the CC list for the bug.