From 753a094e5ec3b1e1df86090e891edb81769c61d8 Mon Sep 17 00:00:00 2001 From: dgaudet Date: Mon, 29 Jan 2007 17:38:58 +0000 Subject: Glob escaping support via backslash. (Andrew Price) git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@786 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 6 ++++++ rdiff-backup/rdiff-backup.1 | 9 +++++++++ rdiff-backup/rdiff_backup/selection.py | 7 +++++-- 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'rdiff-backup') diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index 33d7c48..f4daaa3 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -1,3 +1,9 @@ +New in v1.1.9 (????/??/??) +-------------------------- + +Glob escaping support via backslash. (Andrew Price) + + New in v1.1.8 (2007/01/29) -------------------------- diff --git a/rdiff-backup/rdiff-backup.1 b/rdiff-backup/rdiff-backup.1 index bd93703..a6725f0 100644 --- a/rdiff-backup/rdiff-backup.1 +++ b/rdiff-backup/rdiff-backup.1 @@ -738,6 +738,15 @@ insensitive), then this prefix will be removed and any character in the string can be replaced with an upper- or lowercase version of itself. +If you need to match filenames which contain the above globbing +characters, they may be escaped using a backslash "\\". The backslash +will only escape the character following it so for +.B ** +you will need +to use "\\*\\*" to avoid escaping it to the +.B * +globbing character. + Remember that you may need to quote these characters when typing them into a shell, so the shell does not interpret the globbing patterns before rdiff-backup sees them. diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py index 96b53aa..47bc1ef 100644 --- a/rdiff-backup/rdiff_backup/selection.py +++ b/rdiff-backup/rdiff_backup/selection.py @@ -77,7 +77,7 @@ class Select: """ # This re should not match normal filenames, but usually just globs - glob_re = re.compile("(.*[*?[]|ignorecase\\:)", re.I | re.S) + glob_re = re.compile("(.*[*?[\\\\]|ignorecase\\:)", re.I | re.S) def __init__(self, rootrp): """Select initializer. rpath is the root directory""" @@ -640,7 +640,10 @@ probably isn't what you meant.""" % while i < n: c, s = pat[i], pat[i:i+2] i = i+1 - if s == '**': + if c == '\\': + res = res + re.escape(s[-1]) + i = i + 1 + elif s == '**': res = res + '.*' i = i + 1 elif c == '*': res = res + '[^/]*' -- cgit v1.2.1