aboutsummaryrefslogtreecommitdiff
path: root/cbt
diff options
context:
space:
mode:
Diffstat (limited to 'cbt')
-rwxr-xr-xcbt29
1 files changed, 26 insertions, 3 deletions
diff --git a/cbt b/cbt
index bc369de..e2014ec 100755
--- a/cbt
+++ b/cbt
@@ -290,6 +290,7 @@ stage1 () {
USER_PRESSED_CTRL_C=130
CBT_LOOP_FILE="$CWD/target/.cbt-loop.tmp"
+CBT_KILL_FILE="$CWD/target/.cbt-kill.tmp"
if [ $loop -eq 0 ]; then
which fswatch >/dev/null 2>/dev/null
export fswatch_installed=$?
@@ -305,20 +306,42 @@ while true; do
if [ -f "$CBT_LOOP_FILE" ]; then
rm "$CBT_LOOP_FILE"
fi
+ if [ -f "$CBT_KILL_FILE" ]; then
+ rm "$CBT_KILL_FILE"
+ fi
stage1 "$@"
if [ ! $loop -eq 0 ] || [ $exitCode -eq $USER_PRESSED_CTRL_C ]; then
log "not looping, exiting" "$@"
break
else
+ for file in "${NAILGUN_SOURCES[@]}"; do
+ echo "$file" >> "$CBT_LOOP_FILE"
+ done
files=
if [ -f "$CBT_LOOP_FILE" ]; then
- files=($(cat "$CBT_LOOP_FILE"))
+ files=($(sort "$CBT_LOOP_FILE"))
+ fi
+ pids=
+ if [ -f "$CBT_KILL_FILE" ]; then
+ pids=($(cat "$CBT_KILL_FILE")) # FIXME: should we uniq here?
#rm "$CBT_LOOP_FILE"
fi
echo ""
echo "Watching for file changes... (ctrl+c short press for loop, long press for abort)"
- #echo fswatch --one-event "${NAILGUN_SOURCES[@]}" "${files[@]}"
- fswatch --one-event "${NAILGUN_SOURCES[@]}" "${files[@]}"
+ for file in "${files[@]}"; do
+ if [ $file == "" ]; then
+ echo "warning: empty file found in loop file list" 1>&2
+ fi
+ done
+ fswatch --one-event "${files[@]}"
+ for pid in "${pids[@]}"; do
+ if [ $pid == "" ]; then
+ echo "warning: empty pid found in pid kill list" 1>&2
+ else
+ log "killing process $pid"
+ kill -KILL $pid
+ fi
+ done
fi
done