Skip to content

Instantly share code, notes, and snippets.

@clacke
Forked from derekwyatt/execOnChange.sh
Last active December 15, 2015 23:50
Show Gist options
  • Select an option

  • Save clacke/5343602 to your computer and use it in GitHub Desktop.

Select an option

Save clacke/5343602 to your computer and use it in GitHub Desktop.
Improved quoting and increased the sleep time. With the quoting, you can use any kind of `find` expression without fear that it will be expanded by the shell.
#!/bin/bash
command="$1"
shift
fileSpec=("$@")
sentinel=/tmp/t.$$
touch -t197001010000 $sentinel
while :
do
files=$(find . -newer $sentinel -a '(' "${fileSpec[@]}" ')')
if [ $? != 0 ]; then
exit 1;
fi
if [ "$files" != "" ]; then
$command
touch $sentinel
fi
sleep 0.3
done
execOnChange.sh "bundle exec rspec spec" -path './app/*.rb' -o -path './spec/*.rb'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment