The script below works in bash but not in zsh. I think it is because in the variable OPTS
, I am "expanding" (not sure if this is the right word) the variable $EXCLUDE
, and this syntax doesn't work in zsh. How would I replace that line to make it work on zsh?
SRC="/path_to_source"
DST="/path_to_dest"
EXCLUDE=".hg"
OPTS="-avr --delete --progress --exclude=${EXCLUDE} --delete-excluded"
rsync $OPTS $SRC $DST
Best Answer
The problem here is that
$OPTS
is not split into several arguments on thersync
command line. Inzsh
syntax, use:(an alternative is to simulate standard shell behavior globably with the option
-o shwordsplit
…)From the manpage: