trailing spaces in exclude-from file

Jürgen Bausa Juergen.Bausa at web.de
Mon Jan 24 09:08:25 UTC 2022


I am running debian bullseye which comes with rsync 3.2.3. and was struggling with writing a correct exclude-from file. I want to exclude everything under /tmp and /mnt, but include everything under/mnt/Windows/Users/jba. This is what I came up in the end and what works:

+ /mnt/Windows/Users/jba
+ /mnt/Windows/Users
+ /mnt/Windows
- /mnt/Windows/Users/*
- /mnt/Windows/*
- /mnt/*
- /tmp/*

However, it didn't work in the beginning and took me some time to find out, that a space at the end (e.g. "+ /mnt/Windows/Users " in the second line) will be interpreted and thus, the directory is assumed to be "Users " and not "Users". So with the space it just didn't work.

Is this the intended behavior? Its really hard to find this problem because trailing spaces are normally not directly visible. And they are dropped in every other software (at least the ones I use).

The other thing I was thinking about is, that the above syntax is far from being intuitive. Especially if you have long path names it would be much easier if the following could be used:

+ /mnt/Windows/Users/jba
- /mnt/*
- /tmp/*

In order to not break compatibility a special character (like "!") could be added at the end of the first line. Meaning "match to any subpath of this also". So create /mnt/Windows and /mnt/Windows/Users, but not their contents.

However, that's just a proposal. But the behavior of trailing spaces is something I guess should be corrected.

jba



More information about the rsync mailing list