From 092ab5bbdb5d2f2bc106519745236d475d1c13af Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Tue, 15 Sep 2020 02:06:55 +0800 Subject: [PATCH] Fix the compatibility of fswatch under Linux. (#112) --- tools/run.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/run.sh b/tools/run.sh index ac13b73..938256e 100755 --- a/tools/run.sh +++ b/tools/run.sh @@ -80,7 +80,18 @@ main() { bash _scripts/sh/dump_lastmod.sh if $realtime; then - fswatch -0 -e "/\..*" "$WORK_DIR" | xargs -0 -I {} bash "./${SYNC_TOOL}" {} "$WORK_DIR" . & + + exclude_regex="\/\..*" + + if [[ $OSTYPE == "darwin"* ]]; then + exclude_regex="/\..*" # darwin gcc treat regex '/' as character '/' + fi + + fswatch -e "$exclude_regex" -0 -r \ + --event Created --event Removed \ + --event Updated --event Renamed \ + --event MovedFrom --event MovedTo \ + "$WORK_DIR" | xargs -0 -I {} bash "./${SYNC_TOOL}" {} "$WORK_DIR" . & fi echo "\$ $cmd" @@ -104,7 +115,7 @@ while (($#)); do ;; -b | --baseurl) _check_unset "$2" - if [[ "$2" == \/* ]]; then + if [[ $2 == \/* ]]; then cmd+=" -b $2" else _help