Giter Site home page Giter Site logo

raforg / rawhide Goto Github PK

View Code? Open in Web Editor NEW
45.0 3.0 3.0 666 KB

find files using pretty C expressions

Home Page: https://raf.org/rawhide/

License: GNU General Public License v3.0

Makefile 5.55% C 92.81% Perl 0.62% Shell 1.02%
command-line find linux unix cygwin freebsd netbsd openbsd pcre2 solaris

rawhide's People

Contributors

raforg avatar tavianator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rawhide's Issues

.re hard to use reliably

rh -e '"\.txt$".re'

Matches on a file called foo.txt but also on one called $'foo.txt\nbar.exe' as the PCRE2_MULTILINE (m) flag is enabled by default.

rh -e '"(?-m)\.txt$".re'

Helps but that still matches on a file called $'foo.txt\n' as the PCRE2_DOLLAR_ENDONLY flag is not enabled.

The usual work around (also needed in commands such as perl-based rename implementations) is to use \z in place of $ which always matches at the end of the subject even if PCRE2_MULTILINE is enabled and/or PCRE2_DOLLAR_ENDONLY is not enabled:

rh -e '"\.txt\z".re'

But then I find that it still matches on a file called $'foo.txt\x80bar.exe'. Possibly linked to the PCRE2_MATCH_INVALID_UTF flag.

That sounds like it could be a bug in PCRE2 but I can't reproduce it with pcre2grep -U.

To match on files whose name ends in .txt, I find that I need:

rh -e '"\.txt\z$".re'

Or:

RAWHIDE_PCRE2_NOT_UTF8_DEFAULT=1 rh -e '"\.txt\z".re'

It seems to me pcre2 should be invoked with different default options when it's meant to match on lines (like in .rebody) where using PCRE2_MULTILINE only would make sense and when meant to match on whole strings (like in .re) where PCRE2_DOTALL|PCRE2_DOLLAR_ENDONLY would be more useful (and with PCRE2_EXTENDED|PCRE2_EXTENDED_MORE|PCRE2_NO_AUTO_CAPTURE|PCRE2_UTF|PCRE2_MATCH_INVALID_UTF in common as required).


Note that:

rh -e '"*.txt"'

Would fail to match on $'foo\x80bar.txt' in a UTF-8 locale with the fnmatch() of older versions of glibc which you'd work around by using LC_ALL=C rh -e '"*.txt"' (same as for find -name (or find -regex where supported)). It matches in newer versions but I believe it's because/thanks of that bug.


Context

Here tested with the current git HEAD of rawhide (a1c44e2) on Debian GNU/Linux amd64 with

libc6 2.37-12
libpcre2-8-0 10.42-4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.