>>>>> On Thu, 02 Feb 2006 10:42:22 +0100, Arno Lehmann <[EMAIL PROTECTED]> said:
> 
> Hi,
> 
> On 2/2/2006 1:06 AM, Phil Stracchino wrote:
> > Arno Lehmann wrote:
> > 
> >>By the way, the shell expansion does not use regular expressions...
> >>
> >>To select only stuff starting with a dot, in a regular expression you
> >>should write '\.[^\.].+'. Unless I'm wrong, of course :-)
> >>
> >>That RE would be spelled like "take everything which starts with a dot,
> >>and is followed by one character which is not a dot, and is followed by
> >>at least one character".
> > 
> > 
> > That's not a bad port of the intent of the "standard Unix shell glob
> > trick".  Of course, were someone to name a file simply ".a", both it and
> > the Unix globbing trick would fail.  And, unfprtunately, it is not
> > compliant with the rules of POSIX extended regexes.
> > 
> > To catch ALL dotfiles in Bacula, where . and .. are not concerns, one
> > could simply use the following regex:
> > 
> > '^\..*'
> > 
> > which would denote any filename beginning with a literal . followed by
> > zero or more additional characters.
> > 
> > In a more general environment where . and .. are concerns
> 
> Just to clarify this, and after a short look int the manual, is it 
> correct that Bacula doesn't match directory names against RegExFile 
> patterns? In that case, the REs would definitely become much simpler...

Yes.  It does the following:

if looking at a directory then
  match the whole filename against RegExDir
else
  match the whole filename against RegExFile
endif
match the whole filename against RegEx

It does the same for WildDir, WildFile and Wild.


> > and we don't
> > want recursive selection of current and parent directories, the problem
> > is more complex.  We want to accept filenames beginning with a dot and
> > having at least one additional character, with the restriction that the
> > second character may not also be a dot.  That would look something like
> > this:
> > 
> > '^\.([^.]|\..).*$'
> > 
> > Note that there is NOT a \ escaping the . in the bracket expression.
> 
> Thanks. I was sure I missed something.
> 
> > This is because matching rules are different within POSIX bracket
> > expressions.  Quoting from regex.3:
> > 
> >        To  include  a  literal `]' in the list, make it the first
> >        character (following a possible `^').  To include  a  lit-
> >        eral `-', make it the first or last character, or the sec-
> >        ond endpoint of a range.  To use  a  literal  `-'  as  the
> >        first  endpoint of a range, enclose it in `[.' and `.]' to
> >        make it a collating element (see below).  With the  excep-
> >        tion  of  these  and some combinations using `[' (see next
> >        paragraphs), all other special characters, including  `\',
> >        lose  their  special significance within a bracket expres-
> >        sion.
> > 
> > The important part of that, for our purpose, is the last sentence,
> > because it means that within a [] pair, a \ is just a \, a . is just a
> > ., a psi is just a psi[1].  So not only is it impossible to escape the
> > dot within a bracket expression but, fortunately, we don't need to.
> > 
> > So, the above expression can be read as thus:
> > 
> > ^\.    Match anything which begins with a literal .
> > (      followed by EITHER
> > [^.]   a character which is not a literal .
> > |\..   OR a second literal . followed by ANY character
> > )      (end of the EITHER-OR part)
> > .*     followed by ANY ZERO OR MORE additional characters
> > $      and then ends.
> 
> Great. And now, put that into the manual :-)

With a warning that it won't match anything, because all filenames begin with
a / or a drive letter :-)

__Martin


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to