From 9875612281644a1b3d2dfdc551d48ef1c677a58a Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Fri, 15 Feb 2019 12:49:19 +0300 Subject: [PATCH] Arguments to INW command stored in array --- gitwatch.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gitwatch.sh b/gitwatch.sh index ca5480b..5269dea 100755 --- a/gitwatch.sh +++ b/gitwatch.sh @@ -194,10 +194,10 @@ if [ -d "$1" ]; then # if the target is a directory TARGETDIR=$(sed -e "s/\/*$//" <<<"$IN") # dir to CD into before using git commands: trim trailing slash, if any # construct inotifywait-commandline if [ "$(uname)" != "Darwin" ]; then - INCOMMAND="\"$INW\" -qmr -e \"$EVENTS\" --exclude \"\.git\" \"$TARGETDIR\"" + INW_ARGS=("-qmr" "-e" "$EVENTS" "--exclude" "\.git" "$TARGETDIR") else # still need to fix EVENTS since it wants them listed one-by-one - INCOMMAND="\"$INW\" --recursive \"$EVENTS\" --exclude \"\.git\" \"$TARGETDIR\"" + INW_ARGS=("--recursive" "$EVENTS" "--exclude" "\.git" "$TARGETDIR") fi; GIT_ADD_ARGS="--all ." # add "." (CWD) recursively to index GIT_COMMIT_ARGS="" # add -a switch to "commit" call just to be sure @@ -207,10 +207,10 @@ elif [ -f "$1" ]; then # if the target is a single file TARGETDIR=$(dirname "$IN") # dir to CD into before using git commands: extract from file name # construct inotifywait-commandline if [ "$(uname)" != "Darwin" ]; then - INCOMMAND="\"$INW\" -qm -e \"$EVENTS\" \"$IN\"" + INW_ARGS=("-qm" "-e" "$EVENTS" "$IN") else - INCOMMAND="\"$INW\" \"$EVENTS\" \"$IN\"" - fi; + INW_ARGS=("$EVENTS" "$IN") + fi GIT_ADD_ARGS="$IN" # add only the selected file to index GIT_COMMIT_ARGS="" # no need to add anything more to "commit" call @@ -291,7 +291,7 @@ diff-lines() { # process some time (in case there are a lot of changes or w/e); if there is already a timer # running when we receive an event, we kill it and start a new one; thus we only commit if there # have been no changes reported during a whole timeout period -eval $INCOMMAND | while read -r line; do +eval "$INW" "${INW_ARGS[@]}" | while read -r line; do # is there already a timeout process running? if [[ -n "$SLEEP_PID" ]] && kill -0 $SLEEP_PID &>/dev/null; then # kill it and wait for completion