Skip to content

Add Mac support using fswatch#6

Closed
ChrisPenner wants to merge 2 commits intosharkdp:masterfrom
ChrisPenner:master
Closed

Add Mac support using fswatch#6
ChrisPenner wants to merge 2 commits intosharkdp:masterfrom
ChrisPenner:master

Conversation

@ChrisPenner
Copy link

This should do the trick. I've tested the Mac version, but unfortunately don't have a linux machine to test with so you may just want to double check that it still works 👍

# Watch all files in the current directory

while cfile=$(inotifywait --quiet --format '%w%f' --event close_write,move_self --exclude '\.git' -r .); do
while cfile=$( "${watch_all_cmd[@]}" | head -n1 ); do
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even with the -1 flag fswatch sometimes still outputs multiple changes at once. It seems sensible enough to just print out one of the changed files.

@sharkdp
Copy link
Owner

sharkdp commented Mar 30, 2020

Thank you for your contribution!

I can confirm that it works on Linux, but there seems to be a tiny change in behavior when the watched file/directory is removed.

Apparently, the "File '…' was deleted, waiting for it to reappear .." feature is currently broken on master (oops), but trigger exits cleanly (which is why I haven't noticed this, I had forgotten about the "waiting" feature).

With your PR however, the behavior is different:

If I run

trigger "echo event" /tmp/some-file

in one terminal and then rm /tmp/some-file in another terminal, I get the following output:

File '' was deleted, waiting for it to reappear ................................................

It doesn't ever come back because $cfile is not set correctly (but apparently that doesn't work on master either).

Unrelated from the issue above: why did you choose to use a bash array instead of bash functions (for example)? Just curious.

@sharkdp
Copy link
Owner

sharkdp commented Jul 26, 2020

closing for now (cleaning up list of open PRs).

@sharkdp sharkdp closed this Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants