0👍
The --daemon
option makes inotifywait
put itself into the background immediately. the main process exits immediately, and then $build_script
is executed.
You should monitor the output file and run the build script every time a line is written:
inotifywait --monitor --daemon --outfile "$outfile" --event modify,create,delete --recursive "$watch"
while read -r line; do
"$build_script"
done < "$outfile"
Source:stackexchange.com