parent
777c0d021d
commit
94a3c5750f
92
tar-1.27.1-document-exclude-mistakes.patch
Normal file
92
tar-1.27.1-document-exclude-mistakes.patch
Normal file
@ -0,0 +1,92 @@
|
||||
commit 2c7692bd81946100244f022fdfa47e91afd44632 (document_exclude_mistake)
|
||||
Author: Pavel Raiskup <praiskup@redhat.com>
|
||||
AuthorDate: Mon Mar 31 14:22:56 2014 +0200
|
||||
Commit: Pavel Raiskup <praiskup@redhat.com>
|
||||
CommitDate: Mon Mar 31 14:30:02 2014 +0200
|
||||
|
||||
docs: document common mistake with --exclude
|
||||
|
||||
The default settings of --exclude wildcard matching leads usually
|
||||
to --no-wildcards-match-slash option but there is not obvious that
|
||||
users should also turn --anchored option on.
|
||||
|
||||
* doc/tar.texi: Describe.
|
||||
|
||||
diff --git a/doc/tar.texi b/doc/tar.texi
|
||||
index e3df0c9..395f24c 100644
|
||||
--- a/doc/tar.texi
|
||||
+++ b/doc/tar.texi
|
||||
@@ -7906,6 +7906,73 @@ The following table summarizes pattern-matching default values:
|
||||
@item Exclusion @tab @option{--wildcards --no-anchored --wildcards-match-slash}
|
||||
@end multitable
|
||||
|
||||
+@subsubsection Wildcard matching confusion
|
||||
+Using of @option{--[no-]anchored} and @option{--[no-]wildcards-match-slash}
|
||||
+was proven to make confusion. The reasons for this are probably different
|
||||
+default setting for inclusion and exclusion patterns (in general: you shouldn't
|
||||
+rely on defaults if possible) and maybe also because when using any of these two
|
||||
+options, the position on command line matters (these options should be placed
|
||||
+prior to the member name on command line).
|
||||
+
|
||||
+@noindent
|
||||
+Consider following directory structure:
|
||||
+
|
||||
+@smallexample
|
||||
+$ find path/ | sort
|
||||
+path/
|
||||
+path/file1
|
||||
+path/file2
|
||||
+path/subpath
|
||||
+path/subpath/file1
|
||||
+path/subpath/file2
|
||||
+path/subpath2
|
||||
+path/subpath2/file1
|
||||
+path/subpath2/file2
|
||||
+@end smallexample
|
||||
+
|
||||
+@noindent
|
||||
+To archive full directory @samp{path} except all files named @samp{file1} may be
|
||||
+reached by any of the two following commands:
|
||||
+
|
||||
+@smallexample
|
||||
+$ tar -cf a.tar --no-wildcards-match-slash --no-anchored path \
|
||||
+ --exclude='*/file1'
|
||||
+$ tar -cf a.tar --wildcards-match-slash path --exclude='*/file1'
|
||||
+@end smallexample
|
||||
+
|
||||
+@noindent
|
||||
+Note that the @option{--wildcards-match-slash} and @option{--no-anchored} may be
|
||||
+omitted as it is default for @option{--exclude}. Anyway, we usually want just
|
||||
+concrete file (or rather subset of files with the same name). Assume we want
|
||||
+exclude only files named @samp{file1} from the first subdirectory level.
|
||||
+Following command obviously does not work (it still excludes all files having
|
||||
+@samp{file1} name):
|
||||
+
|
||||
+@smallexample
|
||||
+$ tar -cf a.tar --no-wildcards-match-slash path \
|
||||
+ --exclude='*/file1' | sort
|
||||
+@end smallexample
|
||||
+
|
||||
+@noindent
|
||||
+This is because the @option{--no-anchored} is set by default for exclusion.
|
||||
+What you need to fix is to put @option{--anchored} before pathname:
|
||||
+
|
||||
+@smallexample
|
||||
+$ tar -cvf a.tar --no-wildcards-match-slash --anchored path \
|
||||
+ --exclude='*/file1' | sort
|
||||
+path/
|
||||
+path/file2
|
||||
+path/subpath1/
|
||||
+path/subpath1/file1
|
||||
+path/subpath1/file2
|
||||
+path/subpath2/
|
||||
+path/subpath2/file1
|
||||
+path/subpath2/file2
|
||||
+@end smallexample
|
||||
+
|
||||
+@noindent
|
||||
+Similarly you can exclude second level by specifying @samp{*/*/file1}.
|
||||
+
|
||||
@node quoting styles
|
||||
@section Quoting Member Names
|
||||
|
Loading…
Reference in New Issue
Block a user