-GNU tar NEWS - User visible changes. 2014-11-07
+GNU tar NEWS - User visible changes. 2015-08-03
Please send GNU tar bug reports to <bug-tar@gnu.org>
+\f
+version 1.28.90 (Git)
+
+* New options: --verbatim-files-from, --no-verbatim-files-from
+
+The --verbatim-files-from option instructs tar to treat each line read
+from a file list as a file name, even if it starts with a dash.
+
+File lists are supplied with the --files-from (-T) option. By
+default, each line read from a file list is first stripped off the
+leading and trailing whitespace and, if the result begins with a dash,
+it is treated as tar command line option.
+
+Use the --verbatim-files-from option to disable this special handling.
+This facilitates the use of tar with file lists created automatically
+(e.g. by file(1) command).
+
+This option affects all --files-from options that occur after it in
+the command line. Its effect is reverted by the
+--no-verbatim-files-from option.
+
+* --null option reads file names verbatim
+
+The --null option implies --verbatim-files-from. I.e. each line
+read from null-delimited file lists is treated as a file name.
+
+This restores the documented behavior, which was broken in version
+1.27.
+
\f
version 1.28, 2014-07-28
\f
-Copyright 1994-2001, 2003-2010, 2013-2014 Free Software Foundation, Inc.
+Copyright 1994-2001, 2003-2010, 2013-2015 Free Software Foundation, Inc.
This file is part of GNU tar.
# Configure template for GNU tar. -*- autoconf -*-
-# Copyright 1991, 1994-2010, 2013-2014 Free Software Foundation, Inc.
+# Copyright 1991, 1994-2010, 2013-2015 Free Software Foundation, Inc.
# This file is part of GNU tar.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-AC_INIT([GNU tar], [1.28], [bug-tar@gnu.org])
+AC_INIT([GNU tar], [1.28.90], [bug-tar@gnu.org])
AC_CONFIG_SRCDIR([src/tar.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
Treat all input file or member names literally, do not interpret
escape sequences. @xref{input name quoting}.
+@opsummary{no-verbatim-files-from}
+@item --no-verbatim-files-from
+
+Instructs @GNUTAR{} to treat each line read from a file list as if it
+were supplied in the command line. I.e., leading and trailing
+whitespace is removed and, if the result begins with a dash, it is
+treated as a @GNUTAR{} command line option.
+
+This is default behavior. This option is provided as a way to restore
+it after @option{--verbatim-files-from} option.
+
+It is implied by the @option{--no-null} option.
+
+@xref{no-verbatim-files-from}.
+
@opsummary{no-wildcards}
@item --no-wildcards
Do not use wildcards.
@item --null
When @command{tar} is using the @option{--files-from} option, this option
-instructs @command{tar} to expect file names terminated with @acronym{NUL}, so
-@command{tar} can correctly work with file names that contain newlines.
+instructs @command{tar} to expect file names terminated with
+@acronym{NUL}, and to process file names verbatim.
+
+This means that @command{tar} correctly works with file names that
+contain newlines or begin with a dash.
+
@xref{nul}.
+See also @ref{verbatim-files-from}.
+
@opsummary{numeric-owner}
@item --numeric-owner
Display file modification dates in @acronym{UTC}. This option implies
@option{--verbose}.
+@opsummary{verbatim-files-from}
+@item --verbatim-files-from
+
+Instructs @GNUTAR{} to treat each line read from a file list as a file
+name, even if it starts with a dash.
+
+File lists are supplied with the @option{--files-from} (@option{-T})
+option. By default, each line read from a file list is first trimmed
+off the leading and trailing whitespace and, if the result begins with
+a dash, it is treated as a @GNUTAR{} command line option.
+
+Use the @option{--verbatim-files-from} option to disable this special
+handling. This facilitates the use of @command{tar} with file lists
+created by @command{file} command.
+
+This option affects all @option{--files-from} options that occur after
+it in the command line. Its effect is reverted by the
+@option{--no-verbatim-files-from} option.
+
+This option is implied by the @option{--null} option.
+
+@xref{verbatim-files-from}.
+
@opsummary{verbose}
@item --verbose
@itemx -v
@smallexample
tar (GNU tar) @value{VERSION}
-Copyright (C) 2013-2014 Free Software Foundation, Inc.
+Copyright (C) 2013-2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
you specify either @code{--files-from=-} or @code{-T -}), then the file
names are read from standard input.
-Unless you are running @command{tar} with @option{--create}, you can not use
+Unless you are running @command{tar} with @option{--create}, you cannot use
both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
command.
@end smallexample
@noindent
-In the file list given by @option{-T} option, any file name beginning
-with @samp{-} character is considered a @command{tar} option and is
+By default, each line read from the file list is first stripped off
+any leading and trailing whitespace. If the resulting string begins
+with @samp{-} character, it is considered a @command{tar} option and is
processed accordingly@footnote{Versions of @GNUTAR{} up to 1.15.1
recognized only @option{-C} option in file lists, and only if the
option and its argument occupied two consecutive lines.}. For example,
@end group
@end smallexample
+@anchor{verbatim-files-from}
+@opindex verbatim-files-from
+If such option handling is undesirable, use the
+@option{--verbatim-files-from} option. When this option is in effect,
+each line read from the file list is treated as a file name. Notice,
+that this means, in particular, that no whitespace trimming is
+performed.
+
+@anchor{no-verbatim-files-from}
+@opindex no-verbatim-files-from
+The @option{--verbatim-files-from} affects all @option{-T} options
+that follow it in the command line. The default behavior can be
+restored using @option{--no-verbatim-files-from} option.
+
@opindex add-file
-If you happen to have a file whose name starts with @samp{-},
-precede it with @option{--add-file} option to prevent it from
-being recognized as an option. For example: @code{--add-file=--my-file}.
+To disable option handling for a single file name, use the
+@option{--add-file} option, e.g.: @code{--add-file=--my-file}.
@menu
* nul::
@command{xargs} and @command{cpio}, and is useful with the
@option{-print0} predicate of @acronym{GNU} @command{find}. In
@command{tar}, @option{--null} also disables special handling for
-file names that begin with dash.
+file names that begin with dash (similar to
+@option{--verbatim-files-from} option).
This example shows how to use @command{find} to generate a list of files
larger than 800K in length and put that list into a file called
$ @kbd{tar -c -f foo.tar --files-from list}
@end smallexample
-The interpretation of @option{--directory} is disabled by
-@option{--null} option.
+The interpretation of options in file lists is disabled by
+@option{--verbatim-files-from} and @option{--null} options.
@node absolute
@subsection Absolute File Names
/* Common declarations for the tar program.
- Copyright 1988, 1992-1994, 1996-1997, 1999-2010, 2012-2014 Free
+ Copyright 1988, 1992-1994, 1996-1997, 1999-2010, 2012-2015 Free
Software Foundation, Inc.
This file is part of GNU tar.
/* Unquote filenames */
GLOBAL bool unquote_option;
+/* Treat file names read from -T input verbatim */
+GLOBAL bool verbatim_files_from_option;
+
GLOBAL int savedir_sort_order;
/* Show file or archive names after transformation.
void name_init (void);
void name_add_name (const char *name, int matching_flags);
void name_add_dir (const char *name);
-void name_add_file (const char *name, int term, int matching_flags);
+void name_add_file (const char *name, int term, bool verbatim,
+ int matching_flags);
void name_term (void);
const char *name_next (int change_dirs);
void name_gather (void);
/* Various processing of names.
- Copyright 1988, 1992, 1994, 1996-2001, 2003-2007, 2009, 2013-2014
+ Copyright 1988, 1992, 1994, 1996-2001, 2003-2007, 2009, 2013-2015
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
{
const char *name;/* File name */
int term; /* File name terminator in the list */
+ bool verbatim; /* Verbatim handling of file names: no white-space
+ trimming, no option processing */
FILE *fp;
} file;
} v;
}
void
-name_add_file (const char *name, int term, int matflags)
+name_add_file (const char *name, int term, bool verbatim, int matflags)
{
struct name_elt *ep = name_elt_alloc_matflags (matflags);
ep->type = NELT_FILE;
ep->v.file.name = name;
ep->v.file.term = term;
+ ep->v.file.verbatim = verbatim;
ep->v.file.fp = NULL;
}
\f
case file_list_success:
if (unquote_option)
unquote_string (name_buffer);
- if (handle_option (name_buffer) == 0)
+ if (!ent->v.file.verbatim && handle_option (name_buffer) == 0)
{
name_list_adjust ();
return 1;
/* A tar (tape archiver) program.
- Copyright 1988, 1992-1997, 1999-2001, 2003-2007, 2012-2014 Free
+ Copyright 1988, 1992-1997, 1999-2001, 2003-2007, 2012-2015 Free
Software Foundation, Inc.
Written by John Gilmore, starting 1985-08-25.
NO_SEEK_OPTION,
NO_SELINUX_CONTEXT_OPTION,
NO_UNQUOTE_OPTION,
+ NO_VERBATIM_FILES_FROM_OPTION,
NO_WILDCARDS_MATCH_SLASH_OPTION,
NO_WILDCARDS_OPTION,
NO_XATTR_OPTION,
TRANSFORM_OPTION,
UNQUOTE_OPTION,
UTC_OPTION,
+ VERBATIM_FILES_FROM_OPTION,
VOLNO_FILE_OPTION,
WARNING_OPTION,
WILDCARDS_MATCH_SLASH_OPTION,
{"files-from", 'T', N_("FILE"), 0,
N_("get names to extract or create from FILE"), GRID+1 },
{"null", NULL_OPTION, 0, 0,
- N_("-T reads null-terminated names, disable -C"), GRID+1 },
+ N_("-T reads null-terminated names; implies --verbatim-files-from"),
+ GRID+1 },
{"no-null", NO_NULL_OPTION, 0, 0,
N_("disable the effect of the previous --null option"), GRID+1 },
{"unquote", UNQUOTE_OPTION, 0, 0,
N_("unquote input file or member names (default)"), GRID+1 },
{"no-unquote", NO_UNQUOTE_OPTION, 0, 0,
N_("do not unquote input file or member names"), GRID+1 },
+ {"verbatim-files-from", VERBATIM_FILES_FROM_OPTION, 0, 0,
+ N_("-T reads file names verbatim (no option handling)"), GRID+1 },
+ {"no-verbatim-files-from", NO_VERBATIM_FILES_FROM_OPTION, 0, 0,
+ N_("-T treats file names starting with dash as options (default)"),
+ GRID+1 },
{"exclude", EXCLUDE_OPTION, N_("PATTERN"), 0,
N_("exclude files, given as a PATTERN"), GRID+1 },
{"exclude-from", 'X', N_("FILE"), 0,
break;
case 'T':
- name_add_file (arg, filename_terminator, MAKE_INCL_OPTIONS (args));
+ name_add_file (arg, filename_terminator, verbatim_files_from_option,
+ MAKE_INCL_OPTIONS (args));
/* Indicate we've been given -T option. This is for backward
compatibility only, so that `tar cfT archive /dev/null will
succeed */
case NULL_OPTION:
filename_terminator = '\0';
+ verbatim_files_from_option = true;
break;
case NO_NULL_OPTION:
filename_terminator = '\n';
+ verbatim_files_from_option = false;
break;
case NUMERIC_OWNER_OPTION:
unquote_option = false;
break;
+ case VERBATIM_FILES_FROM_OPTION:
+ verbatim_files_from_option = true;
+ break;
+
+ case NO_VERBATIM_FILES_FROM_OPTION:
+ verbatim_files_from_option = false;
+ break;
+
case WARNING_OPTION:
set_warning_option (arg);
break;
# Makefile for GNU tar regression tests.
-# Copyright 1996-1997, 1999-2001, 2003-2007, 2009, 2012-2013 Free Software
+# Copyright 1996-1997, 1999-2001, 2003-2007, 2009, 2012-2015 Free Software
# This file is part of GNU tar.
T-dir01.at\
T-empty.at\
T-null.at\
+ T-null2.at\
T-rec.at\
T-zfile.at\
T-nonl.at\
--- /dev/null
+# This file is part of test suite for GNU tar. -*- Autotest -*-
+# Copyright 2015 Free Software Foundation, Inc.
+#
+# GNU tar is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# GNU tar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([--null enables verbatim reading])
+AT_KEYWORDS([files-from null T-null2 T-verbatim])
+
+# According to the docs, --null should read each line from the file
+# list verbatim. This feature was broken by commit 26538c9b (tar version
+# 1.27).
+
+AT_TAR_CHECK([
+AT_DATA([file-list],[a
+-b
+--c d
+])
+
+genfile -f a
+genfile -f -b
+genfile -f '--c d'
+
+cat file-list | tr '\n' '\0' | tar -c -f archive -v --null -T -
+],
+[0],
+[a
+-b
+--c d
+],
+[],[],[],[ustar]) # Testing one format is enough
+
+AT_CLEANUP
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
-# Copyright 2004-2008, 2010-2014 Free Software Foundation, Inc.
+# Copyright 2004-2008, 2010-2015 Free Software Foundation, Inc.
# This file is part of GNU tar.
m4_include([T-cd.at])
m4_include([T-empty.at])
m4_include([T-null.at])
+m4_include([T-null2.at])
m4_include([T-zfile.at])
m4_include([T-nonl.at])
m4_include([T-dir00.at])