rsync: Check for new rsync before applying newer options

The newer options for extended attributes or file-flags got reliable
only after rsync v3.1.
This commit is contained in:
Indrajit Raychaudhuri 2021-05-03 18:01:53 -05:00 committed by Indrajit Raychaudhuri
parent 261d3b8224
commit 788aa3d158
1 changed files with 12 additions and 7 deletions

View File

@ -20,14 +20,19 @@ pmodload 'helper'
_rsync_cmd='rsync --verbose --progress --human-readable --compress --archive \
--hard-links --one-file-system'
if grep -q 'xattrs' <(rsync --help 2>&1); then
_rsync_cmd="${_rsync_cmd} --acls --xattrs"
fi
autoload -Uz is-at-least
if is-at-least 3.1 ${"$(rsync --version 2>&1)"[(w)3]}; then
# macOS Enhancements
# https://bombich.com/kb/ccc5/credits
if is-darwin && grep -q 'file-flags' <(rsync --help 2>&1); then
_rsync_cmd="${_rsync_cmd} --crtimes --fileflags --force-change"
# ACL and extended attributes support
if grep -q 'xattrs' <(rsync --help 2>&1); then
_rsync_cmd="${_rsync_cmd} --acls --xattrs"
fi
# macOS Enhancements
# https://bombich.com/kb/ccc5/credits
if is-darwin && grep -q 'file-flags' <(rsync --help 2>&1); then
_rsync_cmd="${_rsync_cmd} --crtimes --fileflags --force-change"
fi
fi
alias rsync-copy="${_rsync_cmd}"