Here is the simplified bit of my code that’s causing problems:
#!/bin/bash
SRC=${BASH_ARGV[1]}
DEST=${BASH_ARGV[0]}
err=""
RSYNC="rsync -Dgoptrl --exclude 'backup-info'"
err=`$RSYNC "$SRC" "$DEST" 2>&1 | xargs -0`;
#err=`rsync -Dgoptrl --exclude 'backup-info' "$SRC" "$DEST" 2>&1 | xargs -0`;
rsync copies everything but directories with the name backup-info do not get excluded. The last line however does work (i.e it does exclude backup-info). They both seem the same to me, so confused as to why one works and the other doesn’t.
Thanks,
Ash
BASH FAQ #50: “I’m trying to put a command in a variable, but the complex cases always fail!”
Put the command in an array, and execute the array.