disable interpretation of trailing slash

John J Foerch jjfoerch at earthlink.net
Sun Jan 8 12:20:47 MST 2012

Wayne Davison <wayned at samba.org> writes:
> One solution is to install a bash script (or setup a bash function) in place of
> the real rsync that strips a single trailing slash from each arg.  That lets
> you specify dir// if you want to copy a dir's contents.  Here's one I did some
> mild tesing on and it appears to work OK:

Wayne Davison <wayned at samba.org> writes:
> On Sat, Jan 7, 2012 at 11:19 PM, Wayne Davison <wayned at samba.org> wrote:
>     Here's one I did some mild tesing on and it appears to work OK:
> I just realized that script would turn the arg "/" into an empty string.
>  You'll want to fix that if you use the idea.  Also, if you want the idiom to
> be optional, you could either (1) have the bash script look for an opt and
> decide if it should do the stripping, or (2) name the script something like
> "rs" or "rsyncs" (or whatever) and use the slash-strip version only when
> desired.

This is definitely a workable idea, and I may use some variant of it,
but here are some thoughts:

 - I wouldn't use the name "rsync" for the wrapper script, because that
   is just setting oneself up for accidents, analogous to the common
   example of why it is a bad idea to 'alias rm="rm -i"': safety-nets
   are fine until you're in a context without them, and you forget that
   they aren't there.

 - Stripping a slash from every argument is not quite the whole story,
   because options which take arguments could have significant trailing

So I may take up your suggestion for my own use, but I did want to put
forward the idea that since in my experience, trailing slash
interpretation is an often-mentioned stumbling-block for rsync users,
maybe it would be appropriate for rsync itself to provide a convenient

Thank you for your time.

John Foerch

More information about the rsync mailing list