Bug 13582 - rsync filters containing multiple adjacent slashes aren't reduced to just one slash before matching
Summary: rsync filters containing multiple adjacent slashes aren't reduced to just one...
Status: RESOLVED WONTFIX
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.1.3
Hardware: x64 Linux
: P5 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-20 05:11 UTC by NyGL4XI0iMRlX6n
Modified: 2018-11-20 22:09 UTC (History)
0 users

See Also:


Attachments
rsync patch to transform every adjacent slashes into one slash (2.82 KB, patch)
2018-08-20 05:11 UTC, NyGL4XI0iMRlX6n
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description NyGL4XI0iMRlX6n 2018-08-20 05:11:17 UTC
Created attachment 14437 [details]
rsync patch to transform every adjacent slashes into one slash

The following test script shows that attempting to exclude the file /sourcedir/a/file2 by using //sourcedir//a//////file2 in the excluded files list, will silently not exclude it because of all those adjacent slashes not being reduced into just one /.


#!/bin/bash

mkdir -p destdir sourcedir/a
touch sourcedir/file1 sourcedir/a/file2
echo 'sourcedir' >/tmp/filesfrom.list.tmp
echo '//sourcedir//a//////file2' >/tmp/excluded.list.tmp #this won't work unless rsync gets patched
#echo '/sourcedir/a/file2' >/tmp/excluded.list.tmp #yes this will work: [sender] hiding file sourcedir/a/file2 because of pattern /sourcedir/a/file2
rsync --recursive --perms --delay-updates --files-from=/tmp/filesfrom.list.tmp --exclude-from=/tmp/excluded.list.tmp --delete-excluded --debug=FILTER1 -- ./ ./destdir/
if test -r 'destdir/sourcedir/a/file2'; then
  echo 'test failed'
else
  echo 'test succeeded'
fi

#cleanup
rm -rf -- destdir sourcedir 
rm -- /tmp/excluded.list.tmp /tmp/filesfrom.list.tmp

I have made a rsync patch(syntax-colored here [1]) in order to squash those consecutive slashes into just one, but I don't know how good it is(it's also quite hacky as you can see) though it does seem ok to me(probably 'cause I made it) and it works just fine. I'm attaching the patch here.


[1] https://gist.github.com/constantoverride/28f5b86493c808849d9d38d7b7ae9685


To be honest I'm not entirely sure this is a bug or just a feature that I wanted rsync to have, so I tried to ask first: https://stackoverflow.com/q/51918909/10239615
Comment 1 Wayne Davison 2018-11-20 22:09:28 UTC
Rsync expects you to supply the args that you want to use in the exclusions, and doesn't tweak them for slashes.