[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: excluding /*/ and /**/
On Sat, Apr 28, 2018 at 01:35:31PM -0400, Robert Bowers wrote:
> >Unfortunately not. As noted in http://www.tarsnap.com/selecting-files.html
> >the behaviour of --include and --exclude comes from BSD tar. For example,
> > "In particular, 'a*b' will match 'foo/a1111/222b/bar"
> > https://github.com/libarchive/libarchive/blob/master/libarchive/archive_match.c#L749
> both of those links are useful and explain all.
> also, wikipedia lied to me. (below the first table)
Interesting! I dug a little deeper, and wikipedia isn't completely wrong here.
libarchive 2.7 uses the POSIX function fnmatch():
By default, fnmatch() acts as I described -- * will match a /
However, if you give it the FNM_PATHNAME flag, then * and ? will
NOT match / !
Given the comment in libarchive, it seems that when they were first writing it,
they decided to deliberately match the behaviour of gtar. This was at latest
in 2008 (that's the first date in the libarchive SVN tree).
(the latest version of libarchive doesn't use fnmatch(), but that comment is
still there, so I assume that they still let * match / )
> >I personally find include & exclude rather confusing. Would the nodump flag
> >work in your case?
> not reliably.
> chattr +d /home/(user)/.cache
> would be fine until a user needed more space and rm -r ~/.cache and killed the flag.
> i run tarsnap from a script so i could just add a section at the top to
> generate an exclude on the fly.
Yes, that's what I'd do. (well, either generate the excludes on the fly, or
set chattr +d on the fly)
> of course, /*/ and /**/ like zsh and newer bash would be kinda nice though.
Definitely! That's one advantage of generating excludes in your own script --
you can use whatever custom shell constructs you want. POSIX and libarchive
have a lot of old backwards-compatible behaviour to take into account (and thus
so does tarsnap).