Bug 10343 - rsync --exclude '*' --include '*' doesn't work as documented
rsync --exclude '*' --include '*' doesn't work as documented
Product: Red Hat Linux
Classification: Retired
Component: rsync (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Depends On:
  Show dependency treegraph
Reported: 2000-03-25 00:34 EST by Steve Coile
Modified: 2014-03-16 22:13 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-04-05 16:11:40 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Steve Coile 2000-03-25 00:34:41 EST
According to the rsync(1) man page (or my interpretation of it), the
following two should be equivalent:

	rsync --exclude '*' --include '*'

However, they are not.  In fact, the "--exclude '*'" seems to dominate all
"--include" options, such that once everything is excluded, nothing can
then be included.  This is in direct contradition with the documentation,
which clearly states (WRT "--include"): "This option tells rsync to not
exclude the specified pattern of filenames."  The example uses of
"--exclude" and "--include" given in the man page also do not work.

Using rsync-2.3.1-1.
Comment 1 Steve Coile 2000-03-25 00:41:59 EST
Ugh.  Make this a documentation enhancement request.  Turns out that the
ordering is significant.  Specifically, if you want to include only specific
files and exclude all else, you need to identify the files to include (using
"--include") *first*, *then* exclude everything else.  Thus, the following are

	rsync --include '*' --exclude '*'

but the following are not:

	rsync --include '*' --exclude '*'   # excludes nothing
	rsync --exclude '*' --include '*'   # excludes everything

The documentation should make this more clear.
Comment 2 Bill Nottingham 2000-04-05 16:11:59 EDT
The current (2.4.2) documentation says:

      o      --include  "*/" --include "*.c" --exclude "*" would
              include all directories and C source files

and, also:

       rsync builds a ordered list of include/exclude options  as
       specified  on the command line. When a filename is encoun-
       tered, rsync checks the name against each  exclude/include
       pattern  in  turn. The first matching pattern is acted on.

This seems to imply that patterns are checked in the order
on the command line.

Note You need to log in before you can comment on or make changes to this bug.