RegExpr in ---exclude

Bernard A Badger bab at vx.com
Mon Jun 24 11:09:01 EST 2002


Just a comment on shell glob usage---see below.
> -----Original Message-----
> From: rsync-admin at lists.samba.org [mailto:rsync-admin at lists.samba.org]On
> Behalf Of tim.conway at philips.com
> Sent: Monday, June 24, 2002 12:29 PM
> To: J.Strohschnitter
> Cc: rsync at lists.samba.org
> Subject: Re: RegExpr in ---exclude
>
[SNIP]
> User Commands                                            rsync(1)
>
> Change
> rsync --exclude "/path/to/*/[Ff][Oo][Ll][Dd][Ee][Rr]"
> to
> rsync --exclude=/path/to/*/[Ff][Oo][Ll][Dd][Ee][Rr]
> and try again.  Frankly, I'm surprised you didn't get a usage message from
> that one.
>
> Note that I removed the quotes.  They are not necessary, since you won't
> get any shell globbing of your pattern, because of the pattern being
> connected to "--exclude" by "=".  The quotes won't break anything, so you
> can leave them in.

Well, sort of.  The "=" isn't special, is just because it's all one "word".

Shell globbing is done before the program is invoked, so
the shell globs on "--exclude=/path/to/*/[Ff][Oo][Ll][Dd][Ee][Rr]", but
unless you have a directory "--exclude=", it won't find anything.
It _does_ look for it, though, so it might be kinda slow in a populous
directory.

It's not strictly necessary, but I don't like to advise other people to do
something that "mostly" works, without making the risks clear.  If you know that
no such directory exists, use it.  Just don't forget that you're using a
loophole.
Isn't there some option in some shell that causes commands to fail if a glob
doesn't generate a result?

If you didn't remember to enter the quotes, you could go ahead because you
know what you're doing.  Command syntax with globs are inherently risky, beware
of files named "-?" like "-r", "-f" and "-q".  That's why the "--" option was
invented, to keep the glob away from the options.

Be extra careful when you are writing shell scripts.  They'll be invoked in
ways you never imagined, so write defensively.





More information about the rsync mailing list