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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
I'm having the same issue/question: https://sourceforge.net/p/snapraid/discussion/1677233/thread/590b5f0f/
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
In the linked documentation, the escape options are either a backslash or quotes. I can't seem to get either option to work.
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:
In the configuration file I would use
But in the command line:
Anyway, using the -l test.log option allow to see what is the argument that SnapRAID sees.
Ciao,
Andrea
Shouldn't this also work?
snapraid check -f 'EXCLUDE\[THIS\]'Double \ escapes for square brackets prevent SnapRAID from running:
Using single \ escapes it will run, but the file is still not matched:
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