diff --git a/scripts/inotifywait.sh b/scripts/inotifywait.sh index 8b2d083..8ff34c3 100755 --- a/scripts/inotifywait.sh +++ b/scripts/inotifywait.sh @@ -29,7 +29,7 @@ function setboolflag { [ "${2}" = "true" ] && echo "${1}"; } function setflag { [ "${2}" != "-" ] && printf "%s=%s" "${1}" "${2}"; } function watch { - inotifywait \ + inotifywait --monitor \ "$(setboolflag --csv "${INOTIFY_CFG_CSV}")" \ "$(setboolflag --no-newline "${INOTIFY_CFG_NO_NEWLINE}")" \ "$(setboolflag --quiet "${INOTIFY_CFG_QUIET}")" \ @@ -42,7 +42,11 @@ function watch { "$(setflag --timefmt "${INOTIFY_CFG_TIMEFMT}")" \ "$(setflag --timeout "${INOTIFY_CFG_TIMEOUT}")" \ $(join " -e " ${INOTIFY_CFG_EVENTS}) \ - "${TARGET}" + "${TARGET}" | \ + while read events; do + log "New event detected in '${TARGET}'" + "${SCRIPT}" ${events} + done } while true; do @@ -54,11 +58,5 @@ while true; do log "Watching events for '${TARGET}'" - events=$(watch) - if [ $? -ne 0 ]; then - sleep 1 - continue - fi - - "${SCRIPT}" ${events} + watch done