raforg / rawhide Goto Github PK
View Code? Open in Web Editor NEWfind files using pretty C expressions
Home Page: https://raf.org/rawhide/
License: GNU General Public License v3.0
find files using pretty C expressions
Home Page: https://raf.org/rawhide/
License: GNU General Public License v3.0
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.