3 ms·
Update, this seems to work: function backup { local SOURCE=$1 local DESTINATION=$2 local ID_RSA=$3 local VALID_SSH="yes"
by liendolucas 3y ago
Update, this seems to work:
function backup {
local SOURCE=$1
local DESTINATION=$2
local ID_RSA=$3
local VALID_SSH="yes"
local RSYNC_OPTIONS=(-av --no-perms --links)
if [[ "${VALID_SSH}" == "yes" ]]; then
RSYNC_OPTIONS+=(-e "ssh -i ${ID_RSA}")
fi
rsync "${RSYNC_OPTIONS[@]}" "${SOURCE}" "${DESTINATION}"
}
I got lucky and found this information with an explanation at: https://www.mail-archive.com/search?l=bug-bash@gnu.org&q=subject:%22help+with+rsync+and+Missing+trailing%5C-%5C%22+in+remote%5C-shell+command.%22&o=newest&f=1 https://www.mail-archive.com/search?l=bug-bash@gnu.org&q=sub...
So, is it a good advice to always use bash arrays to construct arbitrary options for commands?
- saurik 3y agoYes. I read this thread in shock and quite some level of dismay that you weren't using an array :(... I am very glad you came across the correct way to code that :).