emcrisostomo / fswatch

A cross-platform file change monitor with multiple backends: Apple OS X File System Events, *BSD kqueue, Solaris/Illumos File Events Notification, Linux inotify, Microsoft Windows and a stat()-based backend.
https://emcrisostomo.github.io/fswatch/
GNU General Public License v3.0
4.96k stars 327 forks source link

broken exclude on macos? #290

Closed iwelch closed 2 years ago

iwelch commented 2 years ago

I am trying to exclude files prefixed with a period, but they fire nevertheless:

$ fswatch -0 -i "\.md$" -e "\.*" -e "#"  . | xargs -0 -n 1 -I {} echo {}
/Users/me/.ignoreme#.md

I also tried plainer expressions, like -e '^\.* and -e ".*" to exclude dot files and reversing the order of include/exclude, but fswatch always fires when I touch new files whose names are such that should be excluded.

if I am making an error in my spec, maybe another usage example would be good.

emcrisostomo commented 2 years ago

I'm not sure I understand what you're trying to accomplish: you want to exclude all the files prefixed with a period, but you want to include file names that end with .md. Now, fswatch filtering behaviour is simple and it's described here (http://emcrisostomo.github.io/fswatch/doc/1.16.0/fswatch.html/Invoking-fswatch.html#Filtering-by-Path).

The bottomline is that if the path matches an inclusion filter, then it's included. Since your including files ending with .md, then your .ignoreme#.md file is included, since it matches that pattern. The simplest solution, I guess, would be modifying the include filter to be more specific. Also, note that fswatch is filtering the whole path, not just the file name, so your regexp should not just match 'a file starting with a dot', but the actual path.