summaryrefslogtreecommitdiffstats
path: root/onchange
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-09-13 11:43:19 +0200
committerFlorian Pritz <bluewind@xinu.at>2017-09-13 11:43:19 +0200
commit9949ce6fc51c37129c3b390a0715a8945cacc16a (patch)
tree88b6ca4a1b39dfaff41c6dd570c89b3d328861ca /onchange
parentba38291a468363fe3267313b760ae0522616254b (diff)
downloadbin-9949ce6fc51c37129c3b390a0715a8945cacc16a.tar.gz
bin-9949ce6fc51c37129c3b390a0715a8945cacc16a.tar.xz
add new scripts
Signed-off-by: Florian Pritz <bluewind@xinu.at>
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