mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-06-01 04:36:26 +00:00
Options to control option handling in file lists.
The --verbatim-files-from option disables option handling in
file lists. The --no-verbatim-files-from reverts its effect.
The --null option implies --verbatim-files-from. This restores
the documented behavior, broken by 26538c9b.
* src/common.h (verbatim_files_from_option): New global.
* src/names.c (name_elt): New member: file.verbatim
(name_add_file): Take 'verbatim' state as its third parameter.
(read_next_name): Don't call handle_option if file.verbatim
is set.
* src/tar.c: New options --verbatim-files-from and
--no-verbatim-files-from.
* doc/tar.texi: Document --verbatim-files-from and
--no-verbatim-files-from options.
* NEWS: Update.
* configure.ac: Version 1.28.90
* tests/T-null2.at: New testcase.
* tests/Makefile.am: Update.
* tests/testsuite.at: Update.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
@@ -386,6 +386,9 @@ GLOBAL dev_t root_device;
|
||||
/* 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.
|
||||
@@ -727,7 +730,8 @@ int uname_to_uid (char const *uname, uid_t *puid);
|
||||
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);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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
|
||||
@@ -228,6 +228,8 @@ struct name_elt /* A name_array element. */
|
||||
{
|
||||
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;
|
||||
@@ -313,13 +315,14 @@ name_add_dir (const char *name)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -512,7 +515,7 @@ read_next_name (struct name_elt *ent, struct name_elt *ret)
|
||||
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;
|
||||
|
||||
25
src/tar.c
25
src/tar.c
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
@@ -323,6 +323,7 @@ enum
|
||||
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,
|
||||
@@ -364,6 +365,7 @@ enum
|
||||
TRANSFORM_OPTION,
|
||||
UNQUOTE_OPTION,
|
||||
UTC_OPTION,
|
||||
VERBATIM_FILES_FROM_OPTION,
|
||||
VOLNO_FILE_OPTION,
|
||||
WARNING_OPTION,
|
||||
WILDCARDS_MATCH_SLASH_OPTION,
|
||||
@@ -713,13 +715,19 @@ static struct argp_option options[] = {
|
||||
{"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,
|
||||
@@ -1645,7 +1653,8 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
||||
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 */
|
||||
@@ -1906,10 +1915,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
||||
|
||||
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:
|
||||
@@ -2159,6 +2170,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user