@@ -10,15 +10,37 @@ function ctrl_c {
1010}
1111
1212function watch_inotify {
13- inotifywait --recursive \
14- --event modify,move,create,delete \
15- $DIRECTORY_TO_OBSERVE
13+ inotifywait --recursive --monitor --quiet \
14+ --event modify,move,create,delete,attrib \
15+ ${DIRECTORY_TO_OBSERVE} | awk -v SRCD=" ^srcd" -v SUPERSET=" $( pwd) /superset" ' { \
16+ print $0; \
17+ if ($2 ~ "DELETE" || $2 ~ "MOVED_FROM") { \
18+ print "[deleted]: " $1$3; \
19+ print "rm -rf " gensub(SRCD, SUPERSET, 1, $1$3); \
20+ system("rm -rf " gensub(SRCD, SUPERSET, 1, $1$3)); \
21+ } else { \
22+ print "[modified]: " $1$3; \
23+ system("make --no-print-directory apply-patch"); \
24+ } \
25+ }' ;
1626}
1727
1828function watch_fswatch {
19- fswatch --recursive --one-event \
20- --event Created --event Updated --event Removed \
21- ${DIRECTORY_TO_OBSERVE}
29+ fswatch --recursive --event-flags \
30+ --event Created --event Updated --event Removed --event Renamed \
31+ --event MovedFrom --event MovedTo \
32+ --event OwnerModified --event AttributeModified \
33+ ${DIRECTORY_TO_OBSERVE} | awk -v SRCD=" $( pwd) /srcd" -v SUPERSET=" $( pwd) /superset" ' { \
34+ print $0; \
35+ if ($2 ~ "Removed") { \
36+ print "[deleted]: " $1; \
37+ print "rm -rf " gensub(SRCD, SUPERSET, 1, $1); \
38+ system("rm -rf " gensub(SRCD, SUPERSET, 1, $1)); \
39+ } else { \
40+ print "[modified]: " $1; \
41+ system("make --no-print-directory apply-patch"); \
42+ } \
43+ }' ;
2244}
2345
2446
4365
4466make --no-print-directory apply-patch
4567echo -e " \033[1;92mWatching for changes in 'srcd'; using '${whichWatcher} ' ...\033[0m"
46- while watcher; do
47- make --no-print-directory apply-patch
48- done
68+
69+ watcher
0 commit comments