summaryrefslogtreecommitdiffstats
path: root/onchange
diff options
context:
space:
mode:
Diffstat (limited to 'onchange')
-rwxr-xr-xonchange30
1 files changed, 30 insertions, 0 deletions
diff --git a/onchange b/onchange
new file mode 100755
index 0000000..5326d17
--- /dev/null
+++ b/onchange
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+declare -a files
+declare -a command
+
+num_args=$#
+parameters_done=0
+for (( i = 0; i < num_args; i++ )); do
+ case "$1" in
+ --)
+ parameters_done=1
+ shift
+ ;;
+ *)
+ if ((parameters_done)); then
+ command+=("$1")
+ else
+ files+=("$1")
+ fi
+ shift
+ ;;
+ esac
+done
+
+echo "files: ${files[*]}"
+echo "command: ${command[*]}"
+
+while inotifywait -e close_write "${files[@]}"; do
+ "${command[@]}"
+done