diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9aaab69 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +### +### Sudo required +### +sudo: required + + +### +### Set language +### +language: bash + + +### +### Install required software +### +before_install: + - sudo apt-get update + - sudo apt-get install -y shellcheck + + +### +### Run tests +### +script: + - shellcheck --shell=bash watcherd diff --git a/README.md b/README.md index 8733f39..56a458f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # watcherd +[![Build Status](https://travis-ci.org/devilbox/watcherd.svg?branch=master)](https://travis-ci.org/devilbox/watcherd) + watcherd will look for directory changes (added and deleted directories) under the specified path (`-p`) and will execute specified commands or shell scripts (`-a`, `-d`) depending on the event. Once all events have happened during one round (`-i`), a trigger command can be executed (`-t`). Note, the trigger command will only be execute when at least one add or delete command has succeeded with exit code 0. @@ -34,10 +36,10 @@ Required arguments: -p Path to directoy to watch for changes. -a Command to execute when a directory was added. The full path of the new dir will be appended as an argument to - this command. + this command. -d Command to execute when a directory was deletd. The full path of the new dir will be appended as an argument to - this command. + this command. Optional arguments: -t Command to execute after all directories have been added or diff --git a/watcherd b/watcherd index 3e8c787..8240758 100755 --- a/watcherd +++ b/watcherd @@ -278,7 +278,7 @@ if [ "${WATCHER}" = "inotify" ]; then --event delete \ --event move \ --format '%e/\\%w%f' \ - "${WATCH_DIR}" | while read output; do + "${WATCH_DIR}" | while read -r output; do d="${output##*\\}" if [[ "${output}" =~ ^(CREATE|MOVED_TO),ISDIR/\\ ]]; then if action "${d}" "${CMD_ADD}" "ADD" "${VERBOSE}"; then @@ -334,6 +334,6 @@ else ALL_DIRS="${NEW_DIRS}" # Wait before restarting loop - sleep ${INTERVAL} + sleep "${INTERVAL}" done fi