Bash: call make when directory changes

I usually like to use entr when developing on my own hardware to run commands when a directory changes.

However, sometimes I’m working in an environment where I don’t have much control over the availability of helpful programs so many of us take for granted.

I’ve been using Git Bash on Windows, and I’ve been getting tired of hunting down my build terminal, pressing up in my last history to get to the build command, and hitting enter to build my project. I want it to automatically run when I save a new change. But I don’t have entr or any of the other usual suspects to assist me.

So to overcome this problem, with a bit of Internet searching to assist, I wrote a Bash function to watch the src/ directory and build the project when anything in the directory changes (including timestamps, because -l):

monitor_and_build () {
  local sauce=$(ls -l $1)
  while ( true ) ;
  do
    sleep 1
    local newsauce=$(ls -l $1)
    if (( "$sauce" != "$newsauce" )); then
      make
    fi
    local sauce="$newsauce"
  done
}

to be invoked:

$ monitor_and_build src/

Since I did it in such an ad-hoc way, I’m sure I missed a trick or there’s some edge cases this has a problem with. Please review!

Bonus question: aside from the obvious “writing your own programs in Bash is error-prone and foolish” (I admit it took me a few drafts to get it working) – suppose I had entr available, and then what are the benefits of using a program like entr instead?