]> Dogcows Code - chaz/tar/blobdiff - doc/tar.texi
Update
[chaz/tar] / doc / tar.texi
index 74f585b3d225c6e456be44eef8098916dc8033da..7cdf0ddca5de3ed67ca65955148b5aa5408102a4 100644 (file)
@@ -195,6 +195,7 @@ Advanced @GNUTAR{} Operations
 * concatenate::
 * delete::
 * compare::
+* quoting styles::
 
 How to Add Files to Existing Archives: @option{--append}
 
@@ -2592,8 +2593,9 @@ code. @xref{Writing to an External Program}.
 
 @opindex no-quote-chars, summary
 @item --no-quote-chars=@var{string}
-Do not quote characters from @var{string}, even if the selected
-quoting style implies they should be quoted (@FIXME-pxref{Quoting Styles}).
+Remove characters listed in @var{string} from the list of quoted
+characters set by the previous @option{--quote-chars} option
+(@pxref{quoting styles}).
 
 @opindex no-recursion, summary
 @item --no-recursion
@@ -2712,15 +2714,34 @@ anonymous anyway, so that might as well be the owner of anonymous archives.
 
 This option does not affect extraction from archives.
 
+@opindex transform, summary
+@item --transform=@var{sed-expr}
+
+Transform file or member names using @command{sed} replacement expression
+@var{sed-expr}.  For example,
+
+@smallexample
+$ @kbd{tar cf archive.tar --transform 's,^\./,usr/,' .}
+@end smallexample
+
+@noindent
+will add to @file{archive} files from the current working directory,
+replacing initial @samp{./} prefix with @samp{usr/}. For the detailed
+discussion, see @FIXME-xref{transform}
+
+To see transformed member names in verbose listings, use
+@option{--show-transformed-names} option
+(@FIXME-pxref{show-transformed-names}).  
+
 @opindex quote-chars, summary
 @item --quote-chars=@var{string}
 Always quote characters from @var{string}, even if the selected
-quoting style would not quote them (@FIXME-pxref{Quoting Styles}).
+quoting style would not quote them (@pxref{quoting styles}).
 
 @opindex quoting-style, summary
 @item --quoting-style=@var{style}
 Set quoting style to use when printing member and file names
-(@FIXME-pxref{Quoting Styles}). Valid @var{style} values are:
+(@pxref{quoting styles}). Valid @var{style} values are:
 @code{literal}, @code{shell}, @code{shell-always}, @code{c},
 @code{escape}, @code{locale}, and @code{clocale}. Default quoting
 style is @code{escape}, unless overridden while configuring the
@@ -2962,11 +2983,14 @@ $ tar --show-defaults
 Instructs @command{tar} to mention directories its skipping over when
 operating on a @command{tar} archive.  @xref{show-omitted-dirs}.
 
+@opindex show-transformed-names, summary
 @opindex show-stored-names, summary
-@item --show-stored-names
+@item --show-transformed-names
+@itemx --show-stored-names
 
-This option has effect only when used in conjunction with one of
-archive creation operations.  It instructs tar to list the member names
+Display file or member names after applying any transformations
+(@FIXME-pxref{}).  In particular, when used in conjunction with one of
+archive creation operations it instructs tar to list the member names
 stored in the archive, as opposed to the actual file
 names.  @xref{listing member and file names}.
 
@@ -3670,6 +3694,7 @@ it still introduces the info in the chapter correctly : ).}
 * concatenate::
 * delete::
 * compare::
+* quoting styles::
 @end menu
 
 @node Operations
@@ -4171,9 +4196,274 @@ blues
 tar: funk not found in archive
 @end smallexample
 
-The spirit behind the @option{--compare} (@option{--diff}, @option{-d}) option is to check whether the
-archive represents the current state of files on disk, more than validating
-the integrity of the archive media.  For this later goal, @xref{verify}.
+The spirit behind the @option{--compare} (@option{--diff},
+@option{-d}) option is to check whether the archive represents the
+current state of files on disk, more than validating the integrity of
+the archive media.  For this later goal, @xref{verify}. 
+
+@node quoting styles
+@subsection Quoting Member Names
+
+When displaying member names, @command{tar} takes care to avoid
+ambiguities caused by certain characters.  This is called @dfn{name
+quoting}.  The characters in question are:
+
+@itemize @bullet
+@item Non-printable control characters:
+
+@multitable @columnfractions 0.20 0.10 0.60
+@headitem Character @tab ASCII @tab Character name
+@item \a @tab 7  @tab Audible bell
+@item \b @tab 8  @tab Backspace
+@item \f @tab 12 @tab Form feed
+@item \n @tab 10 @tab New line
+@item \r @tab 13 @tab Carriage return
+@item \t @tab 9  @tab Horizontal tabulation
+@item \v @tab 11 @tab Vertical tabulation
+@end multitable
+
+@item Space (ASCII 32)
+
+@item Single and double quotes (@samp{'} and @samp{"})
+
+@item Backslash (@samp{\})
+@end itemize
+
+The exact way @command{tar} uses to quote these characters depends on
+the @dfn{quoting style}.  The default quoting style, called
+@dfn{escape} (see below), uses backslash notation to represent control
+characters, space and backslash.  Using this quoting style, control
+characters are represented as listed in column @samp{Character} in the
+above table, a space is printed as @samp{\ } and a backslash as @samp{\\}.
+
+@GNUTAR{} offers seven distinct quoting styles, which can be selected
+using @option{--quoting-style} option:
+
+@table @option
+@item --quoting-style=@var{style}
+@opindex quoting-style
+
+Sets quoting style.  Valid values for @var{style} argument are:
+literal, shell, shell-always, c, escape, locale, clocale.
+@end table
+
+These styles are described in detail below.  To illustrate their
+effect, we will use an imaginary tar archive @file{arch.tar}
+containing the following members:
+
+@smallexample
+@group
+# 1. Contains horizontal tabulation character.
+a       tab
+# 2. Contains newline character
+a
+newline
+# 3. Contains a space
+a space
+# 4. Contains double quotes
+a"double"quote
+# 5. Contains single quotes
+a'single'quote
+# 6. Contains a backslash character:
+a\backslash
+@end group
+@end smallexample
+
+Here is how usual @command{ls} command would have listed them, if they
+had existed in the current working directory:
+
+@smallexample
+@group
+$ @kbd{ls}
+a\ttab
+a\nnewline
+a\ space
+a"double"quote
+a'single'quote
+a\\backslash
+@end group
+@end smallexample
+
+Quoting styles:
+
+@table @samp
+@item literal
+No quoting, display each character as is:
+
+@smallexample
+@group 
+$ @kbd{tar tf arch.tar --quoting-style=literal}
+./
+./a space
+./a'single'quote
+./a"double"quote
+./a\backslash
+./a    tab
+./a
+newline
+@end group
+@end smallexample
+
+@item shell
+Display characters the same way Bourne shell does:
+control characters, except @samp{\t} and @samp{\n}, are printed using
+backslash escapes, @samp{\t} and @samp{\n} are printed as is, and a
+single quote is printed as @samp{\'}.  If a name contains any quoted
+characters, it is enclosed in single quotes.  In particular, if a name
+contains single quotes, it is printed as several single-quoted strings:
+
+@smallexample
+@group
+$ @kbd{tar tf arch.tar --quoting-style=shell}
+./
+'./a space'
+'./a'\''single'\''quote'
+'./a"double"quote'
+'./a\backslash'
+'./a   tab'
+'./a
+newline'
+@end group
+@end smallexample
+
+@item shell-always
+Same as @samp{shell}, but the names are always enclosed in single
+quotes:
+
+@smallexample
+@group
+$ @kbd{tar tf arch.tar --quoting-style=shell-always}
+'./'
+'./a space'
+'./a'\''single'\''quote'
+'./a"double"quote'
+'./a\backslash'
+'./a   tab'
+'./a
+newline'
+@end group
+@end smallexample
+
+@item c
+Use the notation of the C programming language.  All names are
+enclosed in double quotes.  Control characters are quoted using
+backslash notations, double quotes are represented as @samp{\"},
+backslash characters are represented as @samp{\\}.  Single quotes and
+spaces are not quoted:
+
+@smallexample
+@group
+$ @kbd{tar tf arch.tar --quoting-style=c}
+"./"
+"./a space"
+"./a'single'quote"
+"./a\"double\"quote"
+"./a\\backslash"
+"./a\ttab"
+"./a\nnewline"
+@end group
+@end smallexample
+
+@item escape
+Control characters are printed using backslash notation, a space is
+printed as @samp{\ } and a backslash as @samp{\\}.  This is the
+default quoting style, unless it was changed when configured the
+package.
+
+@smallexample
+@group
+$ @kbd{tar tf arch.tar --quoting-style=escape}
+./
+./a space
+./a'single'quote
+./a"double"quote
+./a\\backslash
+./a\ttab
+./a\nnewline
+@end group
+@end smallexample
+
+@item locale
+Control characters, single quote and backslash are printed using
+backslash notation.  All names are quoted using left and right
+quotation marks, appropriate to the current locale.  If it does not
+define quotation marks, use @samp{`} as left and @samp{'} as right
+quotation marks.  Any occurrences of the right quotation mark in a
+name are escaped with @samp{\}, for example:
+
+For example:
+
+@smallexample
+@group
+$ @kbd{tar tf arch.tar --quoting-style=locale}
+`./'
+`./a space'
+`./a\'single\'quote'
+`./a"double"quote'
+`./a\\backslash'
+`./a\ttab'
+`./a\nnewline'
+@end group
+@end smallexample
+
+@item clocale
+Same as @samp{locale}, but @samp{"} is used for both left and right
+quotation marks, if not provided by the currently selected locale:
+
+@smallexample
+@group
+$ @kbd{tar tf arch.tar --quoting-style=clocale}
+"./"
+"./a space"
+"./a'single'quote"
+"./a\"double\"quote"
+"./a\\backslash"
+"./a\ttab"
+"./a\nnewline"
+@end group
+@end smallexample
+@end table
+
+You can specify which characters should be quoted in addition to those
+implied by the current quoting style:
+
+@table @option
+@item --quote-chars=@var{string}
+Always quote characters from @var{string}, even if the selected
+quoting style would not quote them.
+@end table
+
+For example, using @samp{escape} quoting (compare with the usual
+escape listing above): 
+
+@smallexample
+@group
+$ @kbd{tar tf arch.tar --quoting-style=escape --quote-chars=' "'}
+./
+./a\ space
+./a'single'quote
+./a\"double\"quote
+./a\\backslash
+./a\ttab
+./a\nnewline
+@end group
+@end smallexample
+
+To disable quoting of such additional characters, use the following
+option:
+
+@table @option
+@item --no-quote-chars=@var{string}
+Remove characters listed in @var{string} from the list of quoted
+characters set by the previous @option{--quote-chars} option.
+@end table
+
+This option is particularly useful if you have added
+@option{--quote-chars} to your @env{TAR_OPTIONS} (@pxref{TAR_OPTIONS})
+and wish to disable it for the current invocation.
+
+Note, that @option{--no-quote-chars} does @emph{not} disable those
+characters that are quoted by default in the selected quoting style.
 
 @node create options
 @section Options Used by @option{--create}
This page took 0.033007 seconds and 4 git commands to generate.