[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)
> https://en.wikipedia.org/w/index.php?title=Glob_(programming)&oldid=838363024#Syntax
Interesting! I dug a little deeper, and wikipedia isn't completely wrong here.
libarchive 2.7 uses the POSIX function fnmatch():
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html
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?
> >http://www.tarsnap.com/selecting-files.html
>
> 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).
Cheers,
- Graham