-e escape rule
space.ship.traveller at gmail.com
Thu Oct 20 12:22:32 UTC 2016
> There's no reason to escape an "=" sign in the above command.
Okay, so at a certain level I agree with you and that's how I've fixed
All the stuff about config files is not feasible for a variety of
reasons - I'm aware of those options. I appreciate that you took the
time to explain them.
I think the problem is the assumptions in do_cmd about the contents of
the -e argument.
In my opinion, the way this is split needs to be deferred back to the
user's shell to work correctly. I'm not sure if there is an easy way
to do this that works for any kind of shell.
Assuming that -e is stored into rsh_cmd, and is user supplied for
executing on the shell, the only valid thing you can really do with it
execl("/bin/sh", "sh", "-c", rsh_cmd, (char *) NULL);
(assuming that sh is the user's current shell, might want to use
$SHELL or something else).
It might make more sense if rsh_cmd used string substitution rather
than argument splitting, e.g. -e 'ssh $HOST' this way, no splitting
would be required. In lots of ways this is more flexible. For example,
appending the host might not be useful in some contexts.
Anyway, rsync is pretty awesome. the -e option is only a minor
annoyance, but it would be nice if this discussion could result in a
On 21 October 2016 at 00:03, Paul Slootman <paul+rsync at wurtel.net> wrote:
> On Thu 20 Oct 2016, Samuel Williams wrote:
>> I'm using Ruby's Shellwords module, which generates a string from an
>> array, suitable for shell evaluation.
>> Ruby's implementation prefers escaping whitespace with a backslash
>> rather than quotes. However, this appears to cause some kind of issue
>> in Rsync when it computes argv from -e option.
>> Here is an example command generated by some Ruby code:
>> rsync --archive --stats -e ssh\ -l\ backup\ -i\ /etc/synco/id_rsa\ -o\
>> ConnectTimeout\\\=60\ -o\ BatchMode\\\=yes --link-dest
>> ../../latest/etc/ /etc/
> There's no reason to escape an "=" sign in the above command. Try:
> rsync --archive --stats -e ssh\ -l\ backup\ -i\ /etc/synco/id_rsa\ -o\ ConnectTimeout=60\ -o\ BatchMode=yes --link-dest ../../latest/etc/ /etc/ example.backup.server.com:/tank/backup/servers/blah/latest.snapshot/etc/
> Or even:
> rsync --archive --stats -e ssh\ -i\ /etc/synco/id_rsa\ -o\ ConnectTimeout=60\ -o\ BatchMode=yes --link-dest ../../latest/etc/ /etc/ backup at example.backup.server.com:/tank/backup/servers/blah/latest.snapshot/etc/
> I'd probably create an entry for this host in ~/.ssh/config :
> Host example.backup.server.com
> User backup
> IdentityFile /etc/synco/id_rsa
> ConnectTimeout 60
> and then just use:
> rsync --archive --stats --link-dest ../../latest/etc/ /etc/ example.backup.server.com:/tank/backup/servers/blah/latest.snapshot/etc/
> If you're dynamically doing this, you can pass a config file with -F.
> Please use reply-all for most replies to avoid omitting the mailing list.
> To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
> Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
More information about the rsync