bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with rsync and Missing trailing-" in remote-shell command.


From: Greg Wooledge
Subject: Re: help with rsync and Missing trailing-" in remote-shell command.
Date: Mon, 20 Jun 2016 08:16:02 -0400
User-agent: Mutt/1.4.2.3i

On Fri, Jun 17, 2016 at 01:57:33PM -0700, address@hidden wrote:
> OPTS=(-q -avz --delete -e \'ssh -i /home/$currentuser/.ssh/id_rsa\' 
> --rsync-path=\'sudo rsync\')

You want:

OTPS=(-q -avz --delete -e "ssh -i /home/$currentuser/.ssh/id_rsa"
      --rsync-path="sudo rsync")
OPTS+=( whatever )
rsync "address@hidden"

The entire point of using an array to hold arguments is that each
array element expands to one argument (word).  Each of the "-e" and
"--rsync-path=" options expects its corresponding argument to be a single
word.  The array elements are not passed through an eval step.  So
you simply quote them the same way you would quote them if you were
writing the rsync command without an array expansion step.

Do note that the $currentuser variable must not contain any shell
metacharacters (including spaces), because rsync itself will pass
the arguments of -e and --rsync-path= through a shell evaluation
step.  Shell metacharacters will break at that point, and there is
absolutely nothing you can do about it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]