A quick review of file watchers
38 points
1 month ago
| 7 comments
| anarc.at
| HN
jbreckmckye
27 days ago
[-]
Fun fact, chokidar is a Sanskrit word meaning watchman.

It has an interesting root, it comes from the Proto Indo-European word for "four", because he must watch any enclosure of four walls. This ancient word is the source of the Latin "quartus" which comes into English as "quarter"

The PIE sense is echoed a little in phrases like "living quarters", "give no quarters" etc

reply
laurent_du
27 days ago
[-]
I think you are overreaching a bit. The term 'quarter' in 'give no quarter' derives from the French 'quartier', which referred (in military jargon) to a section of a city or military encampment. Prisoners would be kept in 'quartier de sauveté' and 'donner quartier' is short for 'donner quartier de sauveté'. So I disagree that this is an echo of the PIE meaning. The most likely semantic development is that 'quartier', originally a quarter of something (the fourth part), came to denotate any fraction of a whole, and then was specialized in the military lexicon.
reply
jbreckmckye
27 days ago
[-]
Well, it's uncertain that "quarter" in this sense came from the Middle French. Early Modern English also uses "quarter" to mean "the relations between people", Shakespeare uses it for instance

The actual link is obscure, but I don't think it matters too much - I'm observing a similarity, not attesting an origin.

reply
bjconlan
27 days ago
[-]
It's a shame that fanotify[0] wasn't pointed out in this document also.

Only since seeing it used in 'zigs --watch' impl on Linux[1] (and the fact that I need to enable admin capabilities to run this in a container) has informed me of it's existence.

0. https://docs.kernel.org/admin-guide/filesystem-monitoring.ht...

1. https://ziggit.dev/t/initial-implementation-of-zig-build-wat...

reply
kragen
27 days ago
[-]
This is very timely!

Linux still doesn't have a networked file watching protocol, does it? Like SGI fam, which gamin is based on. I understand SMB/CIFS supports this in the protocol, but Linux clients don't, and I don't remember if Samba does as a server.

inotify is still an ugly and error-prone interface but it does basically work.

What does the situation look like on other free OSes?

A common related requirement is to access a given version of a file, for example so that you know it's consistent with itself. Linux does support so-called "reflinks" for this... but ext4 doesn't. Sad trombone.

reply
vincebowdren
1 month ago
[-]
Listing 33 different file watcher programs for linux, with strengths and weaknesses
reply
simonmic
26 days ago
[-]
A very useful list, thanks! I hope you'll keep updating it.

I guessed the date(s) indicated the tool's approximate period of active development, but apparently not ? Eg watchexec says "2016-2019" but had a major release a few days ago.

[Ah. Because this post is from 2019, and wasn't flagged as such on HN, and the list needs updating.]

reply
gorbachev
27 days ago
[-]
From 2019
reply
fitsumbelay
27 days ago
[-]
`entr` is the homie
reply
simonmic
26 days ago
[-]
It's great, but I switched to watchexec for its easier CLI. (But mac users, watch out for https://github.com/watchexec/watchexec/issues/864, hopefully fixed soon.)
reply
kragen
27 days ago
[-]
What have you used it for? From Anarcat's notes, it sounds like it isn't very generally applicable.
reply
ndr
27 days ago
[-]
It's great for running unit tests on save, or hacking on python script and re-execute them when you need.

I often use something like this when iterating over stuff. This is a quick hack to list files I touched and differ from main.

    git diff main --name-only --relative | entr -r -c my-command
This of course needs to be killed and re-run if you want to pick up new files
reply
kragen
27 days ago
[-]
That's a great tip!
reply