tar: quoting styles
1
1 6.6 Quoting Member Names
1 ========================
1
1 When displaying member names, 'tar' takes care to avoid ambiguities
1 caused by certain characters. This is called "name quoting". The
1 characters in question are:
1
1 * Non-printable control characters:
1 Character ASCII Character name
1 -------------------------------------------------------------------
1 \a 7 Audible bell
1 \b 8 Backspace
1 \f 12 Form feed
1 \n 10 New line
1 \r 13 Carriage return
1 \t 9 Horizontal tabulation
1 \v 11 Vertical tabulation
1
1 * Space (ASCII 32)
1
1 * Single and double quotes (''' and '"')
1
1 * Backslash ('\')
1
1 The exact way 'tar' uses to quote these characters depends on the
1 "quoting style". The default quoting style, called "escape" (see
1 below), uses backslash notation to represent control characters and
1 backslash.
1
1 GNU 'tar' offers seven distinct quoting styles, which can be selected
1 using '--quoting-style' option:
1
1 '--quoting-style=STYLE'
1
1 Sets quoting style. Valid values for STYLE argument are: literal,
1 shell, shell-always, c, escape, locale, clocale.
1
1 These styles are described in detail below. To illustrate their
1 effect, we will use an imaginary tar archive 'arch.tar' containing the
1 following members:
1
1 # 1. Contains horizontal tabulation character.
1 a tab
1 # 2. Contains newline character
1 a
1 newline
1 # 3. Contains a space
1 a space
1 # 4. Contains double quotes
1 a"double"quote
1 # 5. Contains single quotes
1 a'single'quote
1 # 6. Contains a backslash character:
1 a\backslash
1
1 Here is how usual 'ls' command would have listed them, if they had
1 existed in the current working directory:
1
1 $ ls
1 a\ttab
1 a\nnewline
1 a\ space
1 a"double"quote
1 a'single'quote
1 a\\backslash
1
1 Quoting styles:
1
1 'literal'
1 No quoting, display each character as is:
1
1 $ tar tf arch.tar --quoting-style=literal
1 ./
1 ./a space
1 ./a'single'quote
1 ./a"double"quote
1 ./a\backslash
1 ./a tab
1 ./a
1 newline
1
1 'shell'
1 Display characters the same way Bourne shell does: control
1 characters, except '\t' and '\n', are printed using backslash
1 escapes, '\t' and '\n' are printed as is, and a single quote is
1 printed as '\''. If a name contains any quoted characters, it is
1 enclosed in single quotes. In particular, if a name contains
1 single quotes, it is printed as several single-quoted strings:
1
1 $ tar tf arch.tar --quoting-style=shell
1 ./
1 './a space'
1 './a'\''single'\''quote'
1 './a"double"quote'
1 './a\backslash'
1 './a tab'
1 './a
1 newline'
1
1 'shell-always'
1 Same as 'shell', but the names are always enclosed in single
1 quotes:
1
1 $ tar tf arch.tar --quoting-style=shell-always
1 './'
1 './a space'
1 './a'\''single'\''quote'
1 './a"double"quote'
1 './a\backslash'
1 './a tab'
1 './a
1 newline'
1
1 'c'
1 Use the notation of the C programming language. All names are
1 enclosed in double quotes. Control characters are quoted using
1 backslash notations, double quotes are represented as '\"',
1 backslash characters are represented as '\\'. Single quotes and
1 spaces are not quoted:
1
1 $ tar tf arch.tar --quoting-style=c
1 "./"
1 "./a space"
1 "./a'single'quote"
1 "./a\"double\"quote"
1 "./a\\backslash"
1 "./a\ttab"
1 "./a\nnewline"
1
1 'escape'
1 Control characters are printed using backslash notation, and a
1 backslash as '\\'. This is the default quoting style, unless it
1 was changed when configured the package.
1
1 $ tar tf arch.tar --quoting-style=escape
1 ./
1 ./a space
1 ./a'single'quote
1 ./a"double"quote
1 ./a\\backslash
1 ./a\ttab
1 ./a\nnewline
1
1 'locale'
1 Control characters, single quote and backslash are printed using
1 backslash notation. All names are quoted using left and right
1 quotation marks, appropriate to the current locale. If it does not
1 define quotation marks, use ''' as left and as right quotation
1 marks. Any occurrences of the right quotation mark in a name are
1 escaped with '\', for example:
1
1 For example:
1
1 $ tar tf arch.tar --quoting-style=locale
1 './'
1 './a space'
1 './a\'single\'quote'
1 './a"double"quote'
1 './a\\backslash'
1 './a\ttab'
1 './a\nnewline'
1
1 'clocale'
1 Same as 'locale', but '"' is used for both left and right quotation
1 marks, if not provided by the currently selected locale:
1
1 $ tar tf arch.tar --quoting-style=clocale
1 "./"
1 "./a space"
1 "./a'single'quote"
1 "./a\"double\"quote"
1 "./a\\backslash"
1 "./a\ttab"
1 "./a\nnewline"
1
1 You can specify which characters should be quoted in addition to
1 those implied by the current quoting style:
1
1 '--quote-chars=STRING'
1 Always quote characters from STRING, even if the selected quoting
1 style would not quote them.
1
1 For example, using 'escape' quoting (compare with the usual escape
1 listing above):
1
1 $ tar tf arch.tar --quoting-style=escape --quote-chars=' "'
1 ./
1 ./a\ space
1 ./a'single'quote
1 ./a\"double\"quote
1 ./a\\backslash
1 ./a\ttab
1 ./a\nnewline
1
1 To disable quoting of such additional characters, use the following
1 option:
1
1 '--no-quote-chars=STRING'
1 Remove characters listed in STRING from the list of quoted
1 characters set by the previous '--quote-chars' option.
1
1 This option is particularly useful if you have added '--quote-chars'
1 to your 'TAR_OPTIONS' (⇒TAR_OPTIONS) and wish to disable it for
1 the current invocation.
1
1 Note, that '--no-quote-chars' does _not_ disable those characters
1 that are quoted by default in the selected quoting style.
1