regexp support
Ben Escoto
bescoto@stanford.edu
Wed, 10 Apr 2002 16:34:27 -0700
--==_Exmh_1774918441P
Content-Type: text/plain; charset=us-ascii
LDM> I've just read the thread on --exclude --include syntax plans
LDM> for rdiff-backup. Please don't follow the rsync route by using
LDM> their perverted shell globing and rules.
Well, I am almost done with the file selection stuff and have already
added all the perverted globbing stuff. But regexp lovers can
continue to use --exclude-regexp and --include-regexp and ignore the
new --(include|exclude)(-from-filelist)? switches.
>> That's what anchors are for. If you want to match from the
>> beginning then anchor the expression with '^'. At least that's
>> the way it works in Perl (sorry for mentionning that language
>> ;-).
DB> In python, "match" type regex compares must match from the
DB> beginning. "search" regex compares are the ones to use for what
DB> you want. I personally think that Python's "match" is a waste of
DB> space, as search with explicit anchors is more useful.
Ok, although I was inclined in exactly the opposite direction (to
implicitly include $ as well as ^), I changed the behavior of
--(exclude|include)-regexp to use search, so that '--exclude-regexp
foo' will now exclude all the filenames containing 'foo'.
DB> I think an application specific simple syntax can be more
DB> "handy" than a general purpose powerful syntax for a simple
DB> application. I think the rsync extended wildcards are a good
DB> match to this application.
Yes, agreed. For instance, now if a user types in --include **.py
--exclude **, this will search through all the directories for files
ending in '.py' and back up only those directories which have .py
files somewhere in side. This is hard to express via regular
expressions, and it is hard to parse regular expressions to add extra
logic to them.
Another example: if someone tries:
rdiff-backup --exclude bin usr/local /backup
rdiff-backup will notice that "bin" won't match anything in usr/local
and yell until they write:
rdiff-backup --exclude usr/local/bin usr/local /backup
or maybe (depending on what they meant):
rdiff-backup --exclude **/bin usr/local /backup
so having a familiar, but more limited, syntax can help the program
run more checks and keep users from doing things they don't intend.
--
Ben Escoto
--==_Exmh_1774918441P
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Exmh version 2.5 01/15/2001
iD8DBQE8tMwB+owuOvknOnURAkKqAJwOZSRbEdge9iGwDaZ0bSH5qY/4WACfR1Lv
lNsY7KWemyj44QhVF7F373o=
=U5ef
-----END PGP SIGNATURE-----
--==_Exmh_1774918441P--