Skip to content

Watching for hash changes #807

Answered by musjj
musjj asked this question in Questions & Help
Mar 23, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

I ended up using signals instead:

callback() {
  echo hello world
}

trap callback USR1 USR2
watchexec -- kill -USR1 $$ &
trap "kill $!" EXIT
until wait; do
  :
done

watchexec will send a signal to the script itself every time it is triggered. The nice thing here is that you can keep state (e.g. global variables) inbetween runs.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@musjj
Comment options

Answer selected by passcod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants