"-signs in rsync as well as in embedded ssh command

Matt McCutchen hashproduct at verizon.net
Fri Oct 21 15:06:45 GMT 2005


On Fri, 2005-10-21 at 16:44 +0200, Paul Slootman wrote:
> On Fri 21 Oct 2005, Matt McCutchen wrote:
> > 
> > The trouble is that rsync parses the "-e" command into arguments, and it
> > just splits at every whitespace character without regard for the inner
> > quotes.  Maybe rsync should really be calling on a shell to parse the
> > command.
> 
> Would escaping the spaces perhaps also work (in addition to the wrapper
> script)?

No; rsync splits the command at space characters without observing any
of the more sophisticated conventions, such as quoting or escaping, that
shells do.  Here's the relevant excerpt from rsync/main.c :

                static pid_t do_cmd(char *cmd, char *machine, char *user, char *path,
                                    int *f_in, int *f_out)
                {
                        [...]
                                for (tok = strtok(cmd, " "); tok; tok = strtok(NULL, " ")) {
                                        /* Comparison leaves rooms for server_options(). */
                                        if (argc >= MAX_ARGS - MAX_SERVER_ARGS) {
                                                rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n");
                                                exit_cleanup(RERR_SYNTAX);
                                        }
                                        args[argc++] = tok;
                                }
                	[...]
                }

And strtok just looks for occurrences of the indicated character(s) --
here spaces.
-- 
Matt McCutchen, ``hashproduct''
hashproduct at verizon.net -- http://mysite.verizon.net/hashproduct/



More information about the rsync mailing list