Bug 2106 - Spaces in remote filename
Summary: Spaces in remote filename
Status: CLOSED WONTFIX
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 2.6.2
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-30 18:10 UTC by derrick
Modified: 2007-05-11 17:57 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description derrick 2004-11-30 18:10:33 UTC
According to the FAQ:
"It is slightly trickier in rsync because rsync sends a command line
to the remote system to launch the peer copy of rsync. The command
line is interpreted by the remote shell and thus the spaces need
to arrive on the remote system escaped so that the shell doesn't
split such filenames into multiple arguments."

I would argue that the Principle of Least Surprise dictates that rsync should handle any quoting needed 
by the remote system itself rather than make the user do it. If that is not feasible because of unknown 
quoting requirements on the remote system then perhaps the protocol should be enhanced so that the 
command line that is passed to the shell is very simple, like "rsync --server-enhanced" and all the 
"command-line arguments" are actually passed as input to that command as part of the protocol.
Comment 1 Wayne Davison 2004-12-01 00:43:39 UTC
Rsync users exploit this space-splitting behavior to request multiple files from
a remote server, so it cannot be changed at this late date without causing
incompatibilities.

One work around is to use the --files-from option.  For instance, instead of
running this:

rsync -av remote:'/Some\ Path/To/Some\ File.txt' /dest

you could run this:

echo '/Some Path/To/Some File.txt' |
  rsync -av --files-from=- --no-relative remote:/ /dest

It's a little more complicated, but it does work with filesnames that contain
spaces.
Comment 2 Timothee Besset 2007-05-11 16:05:14 UTC
problem with this solution is that having / at the end of the file in the files-from file doesn't work anymore
Comment 3 Wayne Davison 2007-05-11 17:57:51 UTC
(In reply to comment #2)
> problem with this solution is that having / at the end of the file in the
> files-from file doesn't work anymore

I'm not sure what you mean.  A trailing slash has the same meaning in a file-from line when as it does on the command-line:

rsync -av dir/ /var/tmp/newdir/
echo dir/ | rsync -arv --files-from=- --no-relative . /var/tmp/newdir/

Those behave exactly the same way.  Perhaps you missed the --no-relative part?