Created
February 27, 2019 14:21
-
-
Save perpen/7bfa4445f3aab9348da2f4bf4f5b185e to your computer and use it in GitHub Desktop.
inw2 - inotifywait and restart
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 | |
inot_args="-qq -e modify @.git" | |
for arg in "$@"; do | |
case $arg in | |
--) break ;; | |
*) inot_args+=" $arg"; shift ;; | |
esac | |
done | |
shift | |
#echo inot_args: $inot_args | |
#echo rest: $* | |
arg0=$(basename $0) | |
[ -z $1 ] && { | |
echo "Usage: $arg0 <inotifywait opt> ... -- <cmd> <arg> ..." 1>&2 | |
exit 2 | |
} | |
while :; do | |
echo "# Files modified" | |
"$@" & | |
echo "##################################### Done" | |
inotifywait $inot_args || exit 1 | |
pkill -f "^$*\$" | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment