-
-
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.
This file contains hidden or 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.3 | |
| done |
This file contains hidden or 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 "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