Menu

Filter patterns

Help
Quaraxkad
2016-02-24
2016-03-04
  • Quaraxkad

    Quaraxkad - 2016-02-24

    I've had some issues lately with using filters to check/fix single files. I did some tests and it appears that patterns with certain special characters are not properly matched, such as filepaths with [ or ] in them. Do square brackets need to be escaped in a SnapRAID pattern?

     
  • Andrea Mazzoleni

    Hi Quaraxkad and John,

    Yes, escaping is required. SnapRAID uses the "fnmatch" function that uses globbing chars * , ? , and [ ].

    So, they have to be escaped.

    http://man7.org/linux/man-pages/man7/glob.7.html

    Ciao,
    Andrea

     
  • Quaraxkad

    Quaraxkad - 2016-02-28

    In the linked documentation, the escape options are either a backslash or quotes. I can't seem to get either option to work.

     
  • Andrea Mazzoleni

    Hi Quaraxkad,

    If you use the -f option in the command line, likely you need to double the slash to address also the shell quoting.

    For example, If I have a file named:

    EXCLUDE[THIS]
    

    In the configuration file I would use

    exclude EXCLUDE\[THIS\]
    

    But in the command line:

    snapraid check -f EXCLUDE\\[THIS\\]
    

    Anyway, using the -l test.log option allow to see what is the argument that SnapRAID sees.

    Ciao,
    Andrea

     
    • Jessie Taylor

      Jessie Taylor - 2016-02-29

      Shouldn't this also work?

      snapraid check -f 'EXCLUDE\[THIS\]'

       
  • Quaraxkad

    Quaraxkad - 2016-03-02

    Double \ escapes for square brackets prevent SnapRAID from running:

    >snapraid check -f "\Misc\test\\[file\\].txt" -l test2.log
    Invalid filter specification '\Misc\test\\[file\\].txt'
    Filters using relative paths are not supported. Ensure to add an initial slash
    

    Using single \ escapes it will run, but the file is still not matched:

    >snapraid check -f "\Misc\test\[file\].txt" -l test.log
    argv:0:snapraid
    argv:1:-f
    argv:2:\Misc\test\[file\].txt
    argv:3:-l
    argv:4:test.log
    argv:5:check
    ...
    msg:progress: Filtering...
    msg:verbose:    /Misc/test/[file/].txt
    ...
    msg:progress: Initializing...
    msg:progress: Checking...
    msg:status: Nothing to do
    msg:status: Everything OK
    
     
  • Andrea Mazzoleni

    Hi Quaraxkad

    I found the issue. In Windows we cannot use the '\' char for 'escaping' because this char is also the directory separator. In Windows we have to use '^'. But this requires some SnapRAID modifications.

    It will be fixed in 10.1.

    Ciao,
    Andrea

     

Log in to post a comment.

MongoDB Logo MongoDB