GNU Tar Include and Exclude Behavior: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
(→‎Summary: Next release after 1.23 will not act like 1.23)
(update with info from git head)
Line 26: Line 26:
<th align='center'>1.16-22</th>
<th align='center'>1.16-22</th>
<th align='center'>&gt;1.22</th>
<th align='center'>&gt;1.22</th>
<th align='center'>&lt;1.16</th>
<th align='center'>&lt;1.23</th>
<th align='center'>1.16-22</th>
<th align='center'>1.23</th>
<th align='center'>&gt;1.22</th>
<th align='center'>&gt1.23</th>
<th align='center'>&lt;1.16</th>
<th align='center'>&lt;1.23</th>
<th align='center'>1.16-22</th>
<th align='center'>1.23</th>
<th align='center'>&gt;1.22</th>
<th align='center'>&gt;1.23</th>
<th align='center'>&lt;1.16</th>
<th align='center'>&lt;1.23</th>
<th align='center'>1.16-22</th>
<th align='center'>1.23</th>
<th align='center'>&gt;1.22</th>
<th align='center'>&gt;1.23</th>
</tr>
</tr>
<tr>
<tr>
Line 89: Line 89:
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 95: Line 94:
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 173: Line 173:
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 179: Line 178:
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 236: Line 236:
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 242: Line 241:
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 257: Line 257:
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 263: Line 262:
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 299: Line 299:
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
Line 305: Line 304:
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
Line 317: Line 317:
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
Line 326: Line 325:
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 362: Line 362:
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 368: Line 367:
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 404: Line 404:
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 410: Line 409:
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 446: Line 446:
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 452: Line 451:
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#80FF80'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
<td bgcolor='#FF8080'>&nbsp;</td>
Line 458: Line 458:
</table>
</table>


This was tested against tar versions 1.15, 1.15.1, 1.16, 1.17, 1.18, 1.19, 1.20, 1.21, 1.22, and 1.23.
This was tested against tar versions 1.15, 1.15.1, 1.16, 1.17, 1.18, 1.19, 1.20, 1.21, 1.22, 1.23, and the current git HEAD (e21d54e8c).


= Summary =
= Summary =
Line 480: Line 480:
;type &beta;: Only <tt>*?[\</tt> are special, and <tt>\</tt> can escape any character, so <tt>\X</tt> and <tt>X</tt> will both match <tt>X</tt>.  However, both <tt>\?</tt> and <tt>\\</tt> are buggy and will not match <tt>?</tt> and <tt>\</tt>, respectively.
;type &beta;: Only <tt>*?[\</tt> are special, and <tt>\</tt> can escape any character, so <tt>\X</tt> and <tt>X</tt> will both match <tt>X</tt>.  However, both <tt>\?</tt> and <tt>\\</tt> are buggy and will not match <tt>?</tt> and <tt>\</tt>, respectively.
;type &gamma;: Only <tt>*?[\</tt> are special, and <tt>\</tt> can escape any character. There is no bug with <tt>\?</tt> or <tt>\\</tt>.
;type &gamma;: Only <tt>*?[\</tt> are special, and <tt>\</tt> can escape any character. There is no bug with <tt>\?</tt> or <tt>\\</tt>.
;type &delta;: Only <tt>*?[</tt> are special, and no escaping is possible.
;type &delta;: Only <tt>*?[</tt> are special, and no escaping is possible (note that this is a bug in version 1.23)
;type &epsilon;: Only literal matches are accepted, ''except'' that both <tt>\</tt> and <tt>\\</tt> will match <tt>\</tt>.
;type &epsilon;: Only literal matches are accepted, ''except'' that both <tt>\</tt> and <tt>\\</tt> will match <tt>\</tt>.


Line 486: Line 486:
* Explore the inside of character classes: how do you specify ] or \ in a character class?  Negation?
* Explore the inside of character classes: how do you specify ] or \ in a character class?  Negation?
* Look at the source to figure out what's going on with backslashes
* Look at the source to figure out what's going on with backslashes
* Is type &delta; really that limited?

Revision as of 21:27, 26 May 2010

This table represents the results of installcheck/gnutar.pl across multiple GNU Tar versions. Note that this page only deals with include and exclude behavior; see the GNU Tar FAQ entry for other undesirable behaviors.

pat file include exclude
no args -wc -no-wc no args -wc -no-wc
<1.16 1.16-22 >1.22 <1.16 1.16-22 >1.22 <1.16 1.16-22 >1.22 <1.23 1.23 &gt1.23 <1.23 1.23 >1.23 <1.23 1.23 >1.23
./A*AA*A                                    
./A*AAxA                                    
./A\*AA*A                                    
./A\*AAxA                                    
./B?BB?B                                    
./B?BBxB                                    
./B\?BB?B                                    
./B\?BBxB                                    
./C[CC[C                                    
./C\[CC[C                                    
./D\]DD]D                                    
./D]DD]D                                    
./E\EE\E                                    
./E\\EE\E                                    
./F'FF'F                                    
./F\'FF'F                                    
./G"GG"G                                    
./G\"GG"G                                    
./H HH H                                    
./H\ HH H                                    

This was tested against tar versions 1.15, 1.15.1, 1.16, 1.17, 1.18, 1.19, 1.20, 1.21, 1.22, 1.23, and the current git HEAD (e21d54e8c).

Summary

This is the most concise summary I can invent. Yes, there are *five* different matching schemes implemented in GNU tar.

  • Single quotes ('), double quotes ("), and spaces always match themselves exactly, regardless of wildcards.
  • Includes
    • The default behavior is identical to --no-wildcards
    • Behavior changed with version 1.16:
      • In versions before 1.16, the wildcard option is ignored for includes, and type α wildcard matching is always applied.
      • In versions 1.16 and higher, when wildcard matching is enabled, type β wildcard matching is applied. When wildcard matching is disabled, type ε matching is applied (!).
  • Excludes
    • The default behavior is identical to --wildcards
    • When wildcards are disabled, they are truly disabled: only literal matches are accepted.
    • When wildcards are enabled, version 1.23 has a bug that causes incorrect behavior:
      • In versions other than 1.23, when wildcards are enabled, type γ matching is applied.
      • In versions 1.23, when wildcards are enabled, type δ matching is applied.

Matching types mentioned above:

type α
Only *?[\ are special, and only special characters can be escaped by \ - otherwise, the escaping backslash is treated literally (e.g., E\E matches against itself, but not against EE). There is a bug with \?, which is treated as \0177 internally.
type β
Only *?[\ are special, and \ can escape any character, so \X and X will both match X. However, both \? and \\ are buggy and will not match ? and \, respectively.
type γ
Only *?[\ are special, and \ can escape any character. There is no bug with \? or \\.
type δ
Only *?[ are special, and no escaping is possible (note that this is a bug in version 1.23)
type ε
Only literal matches are accepted, except that both \ and \\ will match \.

To Do

  • Explore the inside of character classes: how do you specify ] or \ in a character class? Negation?
  • Look at the source to figure out what's going on with backslashes