Fix the compatibility of fswatch under Linux. (#112)

This commit is contained in:
Cotes Chung 2020-09-15 02:06:55 +08:00
parent e47f73f772
commit 092ab5bbdb
1 changed files with 13 additions and 2 deletions

View File

@ -80,7 +80,18 @@ main() {
bash _scripts/sh/dump_lastmod.sh bash _scripts/sh/dump_lastmod.sh
if $realtime; then 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 fi
echo "\$ $cmd" echo "\$ $cmd"
@ -104,7 +115,7 @@ while (($#)); do
;; ;;
-b | --baseurl) -b | --baseurl)
_check_unset "$2" _check_unset "$2"
if [[ "$2" == \/* ]]; then if [[ $2 == \/* ]]; then
cmd+=" -b $2" cmd+=" -b $2"
else else
_help _help