Mailing List Archive


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

Re: [tlug] Rsync exclusion question



On Thu, Jun 11, 2009 at 10:58 AM, Josh Glover<jmglov@example.com> wrote:
> 2009/6/11 John Fremlin <john@example.com>:
>
>> Which shell expands "*.leases" in double quotes!?
>
> Well, from my tests, not Bash.
>
> Odd, I always thought you had to protect * and ?, but it looks like
> I'm mistaken.
>
> Dunno what is going on with Doug's rsync commands, then.
>
> --
> Cheers,
> Josh

Well, as an update, use of single-quotes instead of double-quotes
seems to have helped.  No over-night sync-errors due to missing .lease
files, so I am pretty satisfied with the outcome.  Still, I am
enjoying this discussion of behavior on the shell with regard to
interpolation.

I think what happened is that the script (written in summary here) did
the following:

#!/bin/bash

rsync -a --exclude "*.lease" host:/path local_path/

If the script was run by, say, a system-user called 'sysuser' (not the
real name), then based on the script above, I think what it did was
interpolate "*.lease" to look for any .lease files in sysuser's home
dir, or wherever it tried to run the script.  And only after that, did
it then run the rsync command.  Since the document repository was
elsewhere on the system, it would naturally find no .lease files and
fail to exclude them.

By using single-quotes, the shell would defer interpolation of the
file-exclusion to the rsync command itself.  In other words, defer and
let rsync sort things out, which is as it should be.

Hopefully I am right.

-- 
Doug McLean

Blog: http://nihonshukyo.wordpress.com/


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links