Escaping Ignore Patterns

I’ve noticed that our nodes are syncing Office temporary files so I’ve decided to start using Ignore Patterns. I’ve read the Wiki over at: https://github.com/syncthing/syncthing/wiki/Ignoring-Files however I can’t seem to get it working.

My .stignore contains: #include .stignorepatterns

The patterns I’ve added to .stignorepatterns are:

~$.doc ~$.docx ~$.ppt ~$.pptx ~$.xls ~$.xlsx

I’ve also tried them with a backslash in front of the ~ and $ characters and it still isn’t working.

Any ideas?

I think you might only need to escape the $

I’ve tried that @AudriusButkevicius. I’ve tried escaping both characters individually and together.

Yeah, I don’t know then. You can probably write a test case and make a pull request fixing it, relevant parts here:

and

https://github.com/syncthing/syncthing/blob/master/internal/fnmatch/fnmatch.go#L53

But I feel that this also might be a windows only thing.

I think this is a bug. The matcher converts the glob patterns to regexps, but doesn’t escape $, ^ and probably some more characters that are special in regexps but not in globs. You should be able to work around it by throwing either one or two \ in front of the dollar sign…

Fixed

1 Like

Thanks @calmh :smile: