Created
September 1, 2012 15:32
-
-
Save derekwyatt/3577440 to your computer and use it in GitHub Desktop.
Executes an arbitrary command when files change.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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.1 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
execOnChange.sh "mvn test" -name \*.java |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment