bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] [PATCH] docs: document common mistake with --exclude


From: Pavel Raiskup
Subject: [Bug-tar] [PATCH] docs: document common mistake with --exclude
Date: Mon, 31 Mar 2014 14:26:45 +0200

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 --no-anchored option on.

* doc/tar.texi: Describe.
---
 doc/tar.texi | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

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
 
address@hidden 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).
+
address@hidden
+Consider following directory structure:
+
address@hidden
+$ find path/ | sort
+path/
+path/file1
+path/file2
+path/subpath
+path/subpath/file1
+path/subpath/file2
+path/subpath2
+path/subpath2/file1
+path/subpath2/file2
address@hidden smallexample
+
address@hidden
+To archive full directory @samp{path} except all files named @samp{file1} may 
be
+reached by any of the two following commands:
+
address@hidden
+$ tar -cf a.tar --no-wildcards-match-slash --no-anchored path \
+      --exclude='*/file1'
+$ tar -cf a.tar --wildcards-match-slash path --exclude='*/file1'
address@hidden smallexample
+
address@hidden
+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
address@hidden name):
+
address@hidden
+$ tar -cf a.tar --no-wildcards-match-slash path \
+    --exclude='*/file1' | sort
address@hidden smallexample
+
address@hidden
+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:
+
address@hidden
+$ 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
address@hidden smallexample
+
address@hidden
+Similarly you can exclude second level by specifying @samp{*/*/file1}.
+
 @node quoting styles
 @section Quoting Member Names
 
-- 
1.9.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]